staging: greybus: audio: Fix possible leak free widgets in gbaudio_dapm_free_controls
PATCH 1/1 staging: greybus: audio: Fix possible leak free widgets in gbaudio_dapm_free_controls
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.
--- drivers/staging/greybus/audio_helper.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/greybus/audio_helper.c +2 -1
@@ -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
Signature · 1 line
2.17.1
Quoted 7 lines · Wang Hai
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".
Quoted 4 lines
Fixes 510e340efe0c ("staging: greybus: audio: Add helper APIs for dynamic audio module")Reported-by Hulk Robot <[email protected]>Signed-off-by Wang Hai <[email protected]>---
--
thanks,
vaibhav
Quoted 5 lines · Wang Hai
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).
Quoted 12 lines
Fixes 510e340efe0c ("staging: greybus: audio: Add helper APIs for dynamic audio module")Reported-by Hulk Robot <[email protected]>Signed-off-by Wang Hai <[email protected]>--- drivers/staging/greybus/audio_helper.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)drivers/staging/greybus/audio_helper.c +0
-0
drivers/staging/greybus/audio_helper.c int gbaudio_dapm_free_controls(struct snd_soc_dapm_context *dapm, · line 142
Quoted 9 lines
drivers/staging/greybus/audio_helper.c +2
-1@@ -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.
Johan
A message that is not in the archive (sent off-list or not yet received): [email protected]
Johan Hovold
maintainerQuoted 7 lines · wanghai (M)
Quoted 5 lines · Johan Hovold
Quoted 4 lines · Wang Hai
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.
Quoted 5 lines
Quoted 3 lines
Quoted 1 line
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