OSDN Git Service

ASoC: soc-dapm.c: fixup snd_soc_dapm_new_control_unlocked() error handling
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Mon, 5 Sep 2022 23:17:57 +0000 (23:17 +0000)
committerMark Brown <broonie@kernel.org>
Wed, 7 Sep 2022 11:44:31 +0000 (12:44 +0100)
commit3caac759681eeb31ac80e3cc14b972680c8bde54
tree9c804cd07a2e46c7fcbca86c42e4f2007e0dff87
parent427de091a7112aa8eaf2f689e95c0dbca5ea6543
ASoC: soc-dapm.c: fixup snd_soc_dapm_new_control_unlocked() error handling

Current snd_soc_dapm_new_control_unlocked() error handling is wrong.
It is using "goto request_failed" (A), but error message is using
"w->name" (B) which is not yet created in such timing.

snd_soc_dapm_new_control_unlocked(xxx)
{
...
switch (w->id) {
case xxx:
...
if (IS_ERR(...)) {
ret = PTR_ERR(...);
(A) goto request_failed;
}
...
}

prefix = soc_dapm_prefix(...);
if (prefix)
(B) w->name = kasprintf(...);
else
(B) w->name = kstrdup_const(...);
...

(A) request_failed:
if (ret != -EPROBE_DEFER)
(B) dev_err(..., w->name, ...);

return ...;
}

we can create "w->name" at beginning of this function.
In such case, we need to call kfree_const(w->name) at error case.
This patch do these.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87wnah8l7e.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/soc-dapm.c