linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: greybus: audio: Add missing unlock in gbaudio_dapm_free_controls()
@ 2020-12-04  2:13 Wang Hai
  2020-12-04  8:40 ` Johan Hovold
  0 siblings, 1 reply; 6+ messages in thread
From: Wang Hai @ 2020-12-04  2:13 UTC (permalink / raw)
  To: johan, elder, gregkh, dan.carpenter, aibhav.sr
  Cc: greybus-dev, devel, linux-kernel

Add the missing unlock before return from function
gbaudio_dapm_free_controls() in the error handling case.

Fixes: 510e340efe0c ("staging: greybus: audio: Add helper APIs for dynamic audio module")
Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Wang Hai <wanghai38@huawei.com>
---
 drivers/staging/greybus/audio_helper.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/staging/greybus/audio_helper.c b/drivers/staging/greybus/audio_helper.c
index 237531ba60f3..293675dbea10 100644
--- a/drivers/staging/greybus/audio_helper.c
+++ b/drivers/staging/greybus/audio_helper.c
@@ -135,6 +135,7 @@ int gbaudio_dapm_free_controls(struct snd_soc_dapm_context *dapm,
 		if (!w) {
 			dev_err(dapm->dev, "%s: widget not found\n",
 				widget->name);
+			mutex_unlock(&dapm->card->dapm_mutex);
 			return -EINVAL;
 		}
 		widget++;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] staging: greybus: audio: Add missing unlock in gbaudio_dapm_free_controls()
  2020-12-04  2:13 [PATCH] staging: greybus: audio: Add missing unlock in gbaudio_dapm_free_controls() Wang Hai
@ 2020-12-04  8:40 ` Johan Hovold
  2020-12-04  9:19   ` wanghai (M)
  2020-12-04 18:02   ` Vaibhav Agarwal
  0 siblings, 2 replies; 6+ messages in thread
From: Johan Hovold @ 2020-12-04  8:40 UTC (permalink / raw)
  To: Wang Hai, Vaibhav Agarwal
  Cc: johan, elder, gregkh, dan.carpenter, aibhav.sr, greybus-dev,
	devel, linux-kernel

On Fri, Dec 04, 2020 at 10:13:50AM +0800, Wang Hai wrote:
> Add the missing unlock before return from function
> gbaudio_dapm_free_controls() in the error handling case.
> 
> Fixes: 510e340efe0c ("staging: greybus: audio: Add helper APIs for dynamic audio module")
> Reported-by: Hulk Robot <hulkci@huawei.com>
> Signed-off-by: Wang Hai <wanghai38@huawei.com>
> ---
>  drivers/staging/greybus/audio_helper.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/staging/greybus/audio_helper.c b/drivers/staging/greybus/audio_helper.c
> index 237531ba60f3..293675dbea10 100644
> --- a/drivers/staging/greybus/audio_helper.c
> +++ b/drivers/staging/greybus/audio_helper.c
> @@ -135,6 +135,7 @@ int gbaudio_dapm_free_controls(struct snd_soc_dapm_context *dapm,
>  		if (!w) {
>  			dev_err(dapm->dev, "%s: widget not found\n",
>  				widget->name);
> +			mutex_unlock(&dapm->card->dapm_mutex);
>  			return -EINVAL;
>  		}
>  		widget++;

This superficially looks correct, but there seems to be another bug in
this function. It can be used free an array of widgets, but if one of
them isn't found we just leak the rest. Perhaps that return should
rather be "widget++; continue;".

Vaibhav?

Johan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] staging: greybus: audio: Add missing unlock in gbaudio_dapm_free_controls()
  2020-12-04  8:40 ` Johan Hovold
@ 2020-12-04  9:19   ` wanghai (M)
  2020-12-04 10:40     ` Johan Hovold
  2020-12-04 18:02   ` Vaibhav Agarwal
  1 sibling, 1 reply; 6+ messages in thread
From: wanghai (M) @ 2020-12-04  9:19 UTC (permalink / raw)
  To: Johan Hovold, Vaibhav Agarwal
  Cc: elder, gregkh, dan.carpenter, aibhav.sr, greybus-dev, devel,
	linux-kernel


在 2020/12/4 16:40, Johan Hovold 写道:
> On Fri, Dec 04, 2020 at 10:13:50AM +0800, Wang Hai wrote:
>> Add the missing unlock before return from function
>> gbaudio_dapm_free_controls() in the error handling case.
>>
>> Fixes: 510e340efe0c ("staging: greybus: audio: Add helper APIs for dynamic audio module")
>> Reported-by: Hulk Robot <hulkci@huawei.com>
>> Signed-off-by: Wang Hai <wanghai38@huawei.com>
>> ---
>>   drivers/staging/greybus/audio_helper.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/staging/greybus/audio_helper.c b/drivers/staging/greybus/audio_helper.c
>> index 237531ba60f3..293675dbea10 100644
>> --- a/drivers/staging/greybus/audio_helper.c
>> +++ b/drivers/staging/greybus/audio_helper.c
>> @@ -135,6 +135,7 @@ int gbaudio_dapm_free_controls(struct snd_soc_dapm_context *dapm,
>>   		if (!w) {
>>   			dev_err(dapm->dev, "%s: widget not found\n",
>>   				widget->name);
>> +			mutex_unlock(&dapm->card->dapm_mutex);
>>   			return -EINVAL;
>>   		}
>>   		widget++;
> This superficially looks correct, but there seems to be another bug in
> this function. It can be used free an array of widgets, but if one of
> them isn't found we just leak the rest. Perhaps that return should
> rather be "widget++; continue;".
>
I think this is a good idea, should I send a v2 patch?
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] staging: greybus: audio: Add missing unlock in gbaudio_dapm_free_controls()
  2020-12-04  9:19   ` wanghai (M)
@ 2020-12-04 10:40     ` Johan Hovold
  0 siblings, 0 replies; 6+ messages in thread
From: Johan Hovold @ 2020-12-04 10:40 UTC (permalink / raw)
  To: wanghai (M)
  Cc: Johan Hovold, Vaibhav Agarwal, elder, gregkh, dan.carpenter,
	greybus-dev, devel, linux-kernel, Mark Greer

On Fri, Dec 04, 2020 at 05:19:25PM +0800, wanghai (M) wrote:
> 
> 在 2020/12/4 16:40, Johan Hovold 写道:
> > On Fri, Dec 04, 2020 at 10:13:50AM +0800, Wang Hai wrote:
> >> Add the missing unlock before return from function
> >> gbaudio_dapm_free_controls() in the error handling case.
> >>
> >> Fixes: 510e340efe0c ("staging: greybus: audio: Add helper APIs for dynamic audio module")
> >> Reported-by: Hulk Robot <hulkci@huawei.com>
> >> Signed-off-by: Wang Hai <wanghai38@huawei.com>
> >> ---
> >>   drivers/staging/greybus/audio_helper.c | 1 +
> >>   1 file changed, 1 insertion(+)
> >>
> >> diff --git a/drivers/staging/greybus/audio_helper.c b/drivers/staging/greybus/audio_helper.c
> >> index 237531ba60f3..293675dbea10 100644
> >> --- a/drivers/staging/greybus/audio_helper.c
> >> +++ b/drivers/staging/greybus/audio_helper.c
> >> @@ -135,6 +135,7 @@ int gbaudio_dapm_free_controls(struct snd_soc_dapm_context *dapm,
> >>   		if (!w) {
> >>   			dev_err(dapm->dev, "%s: widget not found\n",
> >>   				widget->name);
> >> +			mutex_unlock(&dapm->card->dapm_mutex);
> >>   			return -EINVAL;
> >>   		}
> >>   		widget++;
> > This superficially looks correct, but there seems to be another bug in
> > this function. It can be used free an array of widgets, but if one of
> > them isn't found we just leak the rest. Perhaps that return should
> > rather be "widget++; continue;".
> >
> I think this is a good idea, should I send a v2 patch?

Let's just wait a bit and see what Vaibhav or Mark says first.

Johan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] staging: greybus: audio: Add missing unlock in gbaudio_dapm_free_controls()
  2020-12-04  8:40 ` Johan Hovold
  2020-12-04  9:19   ` wanghai (M)
@ 2020-12-04 18:02   ` Vaibhav Agarwal
  2020-12-05 10:44     ` wanghai (M)
  1 sibling, 1 reply; 6+ messages in thread
From: Vaibhav Agarwal @ 2020-12-04 18:02 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Wang Hai, Alex Elder, Greg Kroah-Hartman, Dan Carpenter,
	aibhav.sr, moderated list:GREYBUS SUBSYSTEM, devel, open list

On Fri, Dec 4, 2020 at 2:10 PM Johan Hovold <johan@kernel.org> wrote:
>
> On Fri, Dec 04, 2020 at 10:13:50AM +0800, Wang Hai wrote:
> > Add the missing unlock before return from function
> > gbaudio_dapm_free_controls() in the error handling case.
> >
> > Fixes: 510e340efe0c ("staging: greybus: audio: Add helper APIs for dynamic audio module")
> > Reported-by: Hulk Robot <hulkci@huawei.com>
> > Signed-off-by: Wang Hai <wanghai38@huawei.com>
> > ---
> >  drivers/staging/greybus/audio_helper.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/drivers/staging/greybus/audio_helper.c b/drivers/staging/greybus/audio_helper.c
> > index 237531ba60f3..293675dbea10 100644
> > --- a/drivers/staging/greybus/audio_helper.c
> > +++ b/drivers/staging/greybus/audio_helper.c
> > @@ -135,6 +135,7 @@ int gbaudio_dapm_free_controls(struct snd_soc_dapm_context *dapm,
> >               if (!w) {
> >                       dev_err(dapm->dev, "%s: widget not found\n",
> >                               widget->name);
> > +                     mutex_unlock(&dapm->card->dapm_mutex);
> >                       return -EINVAL;
> >               }
> >               widget++;
>
> This superficially looks correct, but there seems to be another bug in
> this function. It can be used free an array of widgets, but if one of
> them isn't found we just leak the rest. Perhaps that return should
> rather be "widget++; continue;".
>
> Vaibhav?

Thanks Wang for sharing the patch. As already pointed by Johan, this
function indeed has another bug as well.
Pls feel free to share the patch as suggested above.

--
vaibhav

>
> Johan

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] staging: greybus: audio: Add missing unlock in gbaudio_dapm_free_controls()
  2020-12-04 18:02   ` Vaibhav Agarwal
@ 2020-12-05 10:44     ` wanghai (M)
  0 siblings, 0 replies; 6+ messages in thread
From: wanghai (M) @ 2020-12-05 10:44 UTC (permalink / raw)
  To: Vaibhav Agarwal, Johan Hovold
  Cc: Alex Elder, Greg Kroah-Hartman, Dan Carpenter, aibhav.sr,
	moderated list:GREYBUS SUBSYSTEM, devel, open list


在 2020/12/5 2:02, Vaibhav Agarwal 写道:
> On Fri, Dec 4, 2020 at 2:10 PM Johan Hovold <johan@kernel.org> wrote:
>> On Fri, Dec 04, 2020 at 10:13:50AM +0800, Wang Hai wrote:
>>> Add the missing unlock before return from function
>>> gbaudio_dapm_free_controls() in the error handling case.
>>>
>>> Fixes: 510e340efe0c ("staging: greybus: audio: Add helper APIs for dynamic audio module")
>>> Reported-by: Hulk Robot <hulkci@huawei.com>
>>> Signed-off-by: Wang Hai <wanghai38@huawei.com>
>>> ---
>>>   drivers/staging/greybus/audio_helper.c | 1 +
>>>   1 file changed, 1 insertion(+)
>>>
>>> diff --git a/drivers/staging/greybus/audio_helper.c b/drivers/staging/greybus/audio_helper.c
>>> index 237531ba60f3..293675dbea10 100644
>>> --- a/drivers/staging/greybus/audio_helper.c
>>> +++ b/drivers/staging/greybus/audio_helper.c
>>> @@ -135,6 +135,7 @@ int gbaudio_dapm_free_controls(struct snd_soc_dapm_context *dapm,
>>>                if (!w) {
>>>                        dev_err(dapm->dev, "%s: widget not found\n",
>>>                                widget->name);
>>> +                     mutex_unlock(&dapm->card->dapm_mutex);
>>>                        return -EINVAL;
>>>                }
>>>                widget++;
>> This superficially looks correct, but there seems to be another bug in
>> this function. It can be used free an array of widgets, but if one of
>> them isn't found we just leak the rest. Perhaps that return should
>> rather be "widget++; continue;".
>>
>> Vaibhav?
> Thanks Wang for sharing the patch. As already pointed by Johan, this
> function indeed has another bug as well.
> Pls feel free to share the patch as suggested above.
I just sent another patch

"[PATCH] staging: greybus: audio: Fix possible leak free widgets in 
gbaudio_dapm_free_controls"

> Johan
> .
>

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-12-05 10:50 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-04  2:13 [PATCH] staging: greybus: audio: Add missing unlock in gbaudio_dapm_free_controls() Wang Hai
2020-12-04  8:40 ` Johan Hovold
2020-12-04  9:19   ` wanghai (M)
2020-12-04 10:40     ` Johan Hovold
2020-12-04 18:02   ` Vaibhav Agarwal
2020-12-05 10:44     ` wanghai (M)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).