linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging: greybus: audio: Fix possible leak free widgets in gbaudio_dapm_free_controls
@ 2020-12-05 10:38 Wang Hai
  2020-12-05 14:46 ` Vaibhav Agarwal
  2020-12-08  9:35 ` Johan Hovold
  0 siblings, 2 replies; 4+ messages in thread
From: Wang Hai @ 2020-12-05 10:38 UTC (permalink / raw)
  To: johan, vaibhav.sr
  Cc: elder, gregkh, dan.carpenter, aibhav.sr, greybus-dev, devel,
	linux-kernel

In gbaudio_dapm_free_controls(), if one of the widgets is not found, an error
will be returned directly, which will cause the rest to be unable to be freed,
resulting in leak.

This patch fixes the bug. If if one of them is not found, just skip and free the others.

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 | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/greybus/audio_helper.c b/drivers/staging/greybus/audio_helper.c
index 237531ba60f3..3011b8abce38 100644
--- a/drivers/staging/greybus/audio_helper.c
+++ b/drivers/staging/greybus/audio_helper.c
@@ -135,7 +135,8 @@ int gbaudio_dapm_free_controls(struct snd_soc_dapm_context *dapm,
 		if (!w) {
 			dev_err(dapm->dev, "%s: widget not found\n",
 				widget->name);
-			return -EINVAL;
+			widget++;
+			continue;
 		}
 		widget++;
 #ifdef CONFIG_DEBUG_FS
-- 
2.17.1


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

* Re: [PATCH] staging: greybus: audio: Fix possible leak free widgets in gbaudio_dapm_free_controls
  2020-12-05 10:38 [PATCH] staging: greybus: audio: Fix possible leak free widgets in gbaudio_dapm_free_controls Wang Hai
@ 2020-12-05 14:46 ` Vaibhav Agarwal
  2020-12-08  9:35 ` Johan Hovold
  1 sibling, 0 replies; 4+ messages in thread
From: Vaibhav Agarwal @ 2020-12-05 14:46 UTC (permalink / raw)
  To: Wang Hai
  Cc: Johan Hovold, Alex Elder, Greg Kroah-Hartman, Dan Carpenter,
	aibhav.sr, moderated list:GREYBUS SUBSYSTEM, devel, open list

On Sat, Dec 5, 2020 at 4:02 PM Wang Hai <wanghai38@huawei.com> wrote:
>
> In gbaudio_dapm_free_controls(), if one of the widgets is not found, an error
> will be returned directly, which will cause the rest to be unable to be freed,
> resulting in leak.
>
> This patch fixes the bug. If if one of them is not found, just skip and free the others.
>

nit, typo error "If if one".

> 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>
> ---

Reviewed-by: Vaibhav Agarwal <vaibhav.sr@gmail.com>

--
thanks,
vaibhav

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

* Re: [PATCH] staging: greybus: audio: Fix possible leak free widgets in gbaudio_dapm_free_controls
  2020-12-05 10:38 [PATCH] staging: greybus: audio: Fix possible leak free widgets in gbaudio_dapm_free_controls Wang Hai
  2020-12-05 14:46 ` Vaibhav Agarwal
@ 2020-12-08  9:35 ` Johan Hovold
       [not found]   ` <ed57715b-c524-4726-3eaf-434af96d2d92@huawei.com>
  1 sibling, 1 reply; 4+ messages in thread
From: Johan Hovold @ 2020-12-08  9:35 UTC (permalink / raw)
  To: Wang Hai
  Cc: johan, vaibhav.sr, elder, gregkh, dan.carpenter, aibhav.sr,
	greybus-dev, devel, linux-kernel

On Sat, Dec 05, 2020 at 06:38:27PM +0800, Wang Hai wrote:
> In gbaudio_dapm_free_controls(), if one of the widgets is not found, an error
> will be returned directly, which will cause the rest to be unable to be freed,
> resulting in leak.
> 
> This patch fixes the bug. If if one of them is not found, just skip and free the others.

Apart from the typo, please break your lines at 72 columns or so (not
needed for the Fixes tag).

> 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 | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/greybus/audio_helper.c b/drivers/staging/greybus/audio_helper.c
> index 237531ba60f3..3011b8abce38 100644
> --- a/drivers/staging/greybus/audio_helper.c
> +++ b/drivers/staging/greybus/audio_helper.c
> @@ -135,7 +135,8 @@ int gbaudio_dapm_free_controls(struct snd_soc_dapm_context *dapm,
>  		if (!w) {
>  			dev_err(dapm->dev, "%s: widget not found\n",
>  				widget->name);
> -			return -EINVAL;
> +			widget++;
> +			continue;
>  		}
>  		widget++;
>  #ifdef CONFIG_DEBUG_FS

Not sure if we can ever have the widget lookup fail, but at least this
looks consistent now.

Reviewed-by: Johan Hovold <johan@kernel.org>

Johan

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

* Re: [PATCH] staging: greybus: audio: Fix possible leak free widgets in gbaudio_dapm_free_controls
       [not found]   ` <ed57715b-c524-4726-3eaf-434af96d2d92@huawei.com>
@ 2020-12-14  9:48     ` Johan Hovold
  0 siblings, 0 replies; 4+ messages in thread
From: Johan Hovold @ 2020-12-14  9:48 UTC (permalink / raw)
  To: wanghai (M)
  Cc: Johan Hovold, vaibhav.sr, elder, gregkh, dan.carpenter,
	aibhav.sr, greybus-dev, devel, linux-kernel

On Fri, Dec 11, 2020 at 08:29:22PM +0800, wanghai (M) wrote:
> 
> 在 2020/12/8 17:35, Johan Hovold 写道:
> > On Sat, Dec 05, 2020 at 06:38:27PM +0800, Wang Hai wrote:
> >> In gbaudio_dapm_free_controls(), if one of the widgets is not found, an error
> >> will be returned directly, which will cause the rest to be unable to be freed,
> >> resulting in leak.
> >>
> >> This patch fixes the bug. If if one of them is not found, just skip and free the others.
> > Apart from the typo, please break your lines at 72 columns or so (not
> > needed for the Fixes tag).
>
> Thanks for review,  Do I need to send a v2 patch to change the commit msg?

I'm not sure your mail reached the lists since it contains HTML, but to
answer your question: Please do resend. If you can make the maintainers'
life any easier that's always a good idea.

You should include the Reviewed-by tags you've gotten so far when
resending as long as you only update the commit message.

Johan

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

end of thread, other threads:[~2020-12-14  9:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-05 10:38 [PATCH] staging: greybus: audio: Fix possible leak free widgets in gbaudio_dapm_free_controls Wang Hai
2020-12-05 14:46 ` Vaibhav Agarwal
2020-12-08  9:35 ` Johan Hovold
     [not found]   ` <ed57715b-c524-4726-3eaf-434af96d2d92@huawei.com>
2020-12-14  9:48     ` Johan Hovold

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).