staging: greybus: audio: Add missing unlock in gbaudio_dapm_free_controls()
PATCH 1/1 staging: greybus: audio: Add missing unlock in gbaudio_dapm_free_controls()
Add the missing unlock before return from function gbaudio_dapm_free_controls() in the error handling case.
--- drivers/staging/greybus/audio_helper.c | 1 + 1 file changed, 1 insertion(+)
drivers/staging/greybus/audio_helper.c +1 -0
@@ -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++;
Signature · 1 line
2.17.1
Johan Hovold
maintainerQuoted 15 lines · Wang Hai
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 <[email protected]>Signed-off-by Wang Hai <[email protected]>--- drivers/staging/greybus/audio_helper.c | 1 + 1 file changed, 1 insertion(+)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 141
Quoted 7 lines
drivers/staging/greybus/audio_helper.c +1
-0@@ -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
Quoted 11 lines · Johan Hovold
Quoted 10 lines · Wang Hai
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 <[email protected]>Signed-off-by Wang Hai <[email protected]>--- drivers/staging/greybus/audio_helper.c | 1 + 1 file changed, 1 insertion(+)
Quoted 17 lines
drivers/staging/greybus/audio_helper.c int gbaudio_dapm_free_controls(struct snd_soc_dapm_context *dapm, · line 141
Quoted 12 lines
drivers/staging/greybus/audio_helper.c +1
-0@@ -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?
Quoted 1 line
Johan Hovold
maintainerQuoted 30 lines · wanghai (M)
Quoted 11 lines · Johan Hovold
Quoted 10 lines · Wang Hai
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 <[email protected]>Signed-off-by Wang Hai <[email protected]>--- drivers/staging/greybus/audio_helper.c | 1 + 1 file changed, 1 insertion(+)Quoted 17 lines
drivers/staging/greybus/audio_helper.c int gbaudio_dapm_free_controls(struct snd_soc_dapm_context *dapm, · line 141
Quoted 12 lines
drivers/staging/greybus/audio_helper.c +1
-0@@ -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;".
Quoted 1 line
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
Quoted 30 lines · Johan Hovold
Quoted 15 lines · Wang Hai
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 <[email protected]>Signed-off-by Wang Hai <[email protected]>--- drivers/staging/greybus/audio_helper.c | 1 + 1 file changed, 1 insertion(+)drivers/staging/greybus/audio_helper.c +0
-0drivers/staging/greybus/audio_helper.c int gbaudio_dapm_free_controls(struct snd_soc_dapm_context *dapm, · line 141
Quoted 7 lines
drivers/staging/greybus/audio_helper.c +1
-0@@ -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;".
Quoted 1 line
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
Quoted 2 lines
Johan
Quoted 29 lines · Vaibhav Agarwal
Quoted 28 lines · Johan Hovold
Quoted 15 lines · Wang Hai
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 <[email protected]>Signed-off-by Wang Hai <[email protected]>--- drivers/staging/greybus/audio_helper.c | 1 + 1 file changed, 1 insertion(+)drivers/staging/greybus/audio_helper.c +0
-0drivers/staging/greybus/audio_helper.c int gbaudio_dapm_free_controls(struct snd_soc_dapm_context *dapm, · line 141
Quoted 7 lines
drivers/staging/greybus/audio_helper.c +1
-0@@ -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;".
Quoted 4 lines
Quoted 1 line
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"
Quoted 3 lines
Johan
.