2014-12-03 16:39:27

by Andrew Jackson

[permalink] [raw]
Subject: [PATCH 2/5] ASoC: dwc: Don't allow negative use counts


Signed-off-by: Andrew Jackson <[email protected]>
---
sound/soc/dwc/designware_i2s.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/sound/soc/dwc/designware_i2s.c b/sound/soc/dwc/designware_i2s.c
index 08f0229..f8946bd 100644
--- a/sound/soc/dwc/designware_i2s.c
+++ b/sound/soc/dwc/designware_i2s.c
@@ -280,7 +280,8 @@ static int dw_i2s_trigger(struct snd_pcm_substream *substream,
case SNDRV_PCM_TRIGGER_STOP:
case SNDRV_PCM_TRIGGER_SUSPEND:
case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
- dev->active--;
+ if (dev->active > 0)
+ dev->active--;
i2s_stop(dev, substream);
break;
default:
--
1.7.1


2014-12-03 17:25:40

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 2/5] ASoC: dwc: Don't allow negative use counts

On Wed, Dec 03, 2014 at 04:38:55PM +0000, Andrew Jackson wrote:

> case SNDRV_PCM_TRIGGER_STOP:
> case SNDRV_PCM_TRIGGER_SUSPEND:
> case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
> - dev->active--;
> + if (dev->active > 0)
> + dev->active--;

How is this triggering - this sounds like you're papering over some
other bug somewhere?


Attachments:
(No filename) (330.00 B)
signature.asc (473.00 B)
Digital signature
Download all attachments

2014-12-04 06:40:20

by rajeev kumar

[permalink] [raw]
Subject: Re: [PATCH 2/5] ASoC: dwc: Don't allow negative use counts

On Wed, Dec 3, 2014 at 10:55 PM, Mark Brown <[email protected]> wrote:
> On Wed, Dec 03, 2014 at 04:38:55PM +0000, Andrew Jackson wrote:
>
>> case SNDRV_PCM_TRIGGER_STOP:
>> case SNDRV_PCM_TRIGGER_SUSPEND:
>> case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
>> - dev->active--;
>> + if (dev->active > 0)
>> + dev->active--;
>
> How is this triggering - this sounds like you're papering over some
> other bug somewhere?

2014-12-04 06:43:49

by rajeev kumar

[permalink] [raw]
Subject: Re: [PATCH 2/5] ASoC: dwc: Don't allow negative use counts

On Thu, Dec 4, 2014 at 12:10 PM, rajeev kumar
<[email protected]> wrote:
> On Wed, Dec 3, 2014 at 10:55 PM, Mark Brown <[email protected]> wrote:
>> On Wed, Dec 03, 2014 at 04:38:55PM +0000, Andrew Jackson wrote:
>>
>>> case SNDRV_PCM_TRIGGER_STOP:
>>> case SNDRV_PCM_TRIGGER_SUSPEND:
>>> case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
>>> - dev->active--;
>>> + if (dev->active > 0)
>>> + dev->active--;
>>
>> How is this triggering - this sounds like you're papering over some
>> other bug somewhere?

This check can be removed as it is not going to triggered.

B'rgds
~Rajeev

2014-12-04 09:01:08

by Andrew Jackson

[permalink] [raw]
Subject: Re: [PATCH 2/5] ASoC: dwc: Don't allow negative use counts

On 12/03/14 17:25, Mark Brown wrote:
> On Wed, Dec 03, 2014 at 04:38:55PM +0000, Andrew Jackson wrote:
>
>> case SNDRV_PCM_TRIGGER_STOP:
>> case SNDRV_PCM_TRIGGER_SUSPEND:
>> case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
>> - dev->active--;
>> + if (dev->active > 0)
>> + dev->active--;
>
> How is this triggering - this sounds like you're papering over some
> other bug somewhere?
>

When I looked at the code paths I couldn't convince myself that STOP wouldn't be called more than once. Then actuve would be negative and the device might not be restartable. I didn't have a problem per se, it was just that it seemed to be something of a loophole.

Andrew

2014-12-04 09:08:26

by Andrew Jackson

[permalink] [raw]
Subject: Re: [PATCH 2/5] ASoC: dwc: Don't allow negative use counts

On 12/04/14 06:43, rajeev kumar wrote:
> On Thu, Dec 4, 2014 at 12:10 PM, rajeev kumar
> <[email protected]> wrote:
>> On Wed, Dec 3, 2014 at 10:55 PM, Mark Brown <[email protected]> wrote:
>>> On Wed, Dec 03, 2014 at 04:38:55PM +0000, Andrew Jackson wrote:
>>>
>>>> case SNDRV_PCM_TRIGGER_STOP:
>>>> case SNDRV_PCM_TRIGGER_SUSPEND:
>>>> case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
>>>> - dev->active--;
>>>> + if (dev->active > 0)
>>>> + dev->active--;
>>>
>>> How is this triggering - this sounds like you're papering over some
>>> other bug somewhere?
>
> This check can be removed as it is not going to triggered.

As I said in my email to Mark, I couldn't convince myself that STOP/SUSPEND would only be called once so it seemed like a loophole which /might/ result in the device not functioning correctly.

If this can never happen, I'll drop the patch.

Andrew

> B'rgds
> ~Rajeev
>

2014-12-04 10:51:46

by Mark Brown

[permalink] [raw]
Subject: Re: [PATCH 2/5] ASoC: dwc: Don't allow negative use counts

On Thu, Dec 04, 2014 at 09:00:35AM +0000, Andrew Jackson wrote:
> On 12/03/14 17:25, Mark Brown wrote:
> > On Wed, Dec 03, 2014 at 04:38:55PM +0000, Andrew Jackson wrote:

> >> case SNDRV_PCM_TRIGGER_STOP:
> >> case SNDRV_PCM_TRIGGER_SUSPEND:
> >> case SNDRV_PCM_TRIGGER_PAUSE_PUSH:
> >> - dev->active--;
> >> + if (dev->active > 0)
> >> + dev->active--;

> > How is this triggering - this sounds like you're papering over some
> > other bug somewhere?

> When I looked at the code paths I couldn't convince myself that STOP
> wouldn't be called more than once. Then actuve would be negative and
> the device might not be restartable. I didn't have a problem per se,
> it was just that it seemed to be something of a loophole.

If you're just adding the check on the off chance that it might fire you
need to add a warning message as well - what your change does is make
the code look like it's supposed to have broken reference counting since
it has a check to silently fix up and ignore problems.


Attachments:
(No filename) (0.99 kB)
signature.asc (473.00 B)
Digital signature
Download all attachments