Skip to contentSkip to conversation

staging: greybus: audio: Fix possible leak free widgets in gbaudio_dapm_free_controls

PATCH In review Wang Hai 3 participants 4 messages Dec 5, 2020 – Dec 14, 2020 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

Wang Hai

author
#0 lore raw

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.

Fixes 510e340efe0c ("staging: greybus: audio: Add helper APIs for dynamic audio module")
---
 drivers/staging/greybus/audio_helper.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/greybus/audio_helper.c +2 -1
index 237531ba60f3..3011b8abce38 100644
@@ -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
Reviewed-by on v1 1/1
#1 lore raw
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")

---

--
thanks,
vaibhav

maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Wang Hai
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")
---
 drivers/staging/greybus/audio_helper.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/staging/greybus/audio_helper.c +0 -0
index 237531ba60f3..3011b8abce38 100644

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]

maintainer
#4 lore raw
Quoted 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