[PATCH 0/2] ASoC: soc-core: tidyup error handling for rtd
Hi Mark
These are small clanup patches for soc-core. [1/2] patch adds missing explanation, and [2/2] patch fixup error handling of rtd.
Kuninori Morimoto (2): ASoC: soc-core: add comment for rtd freeing ASoC: soc-core: use device_unregister() if rtd allocation failed
sound/soc/soc-core.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
We don't need to mind freeing for rtd, because it was created from devm_kzalloc(dev, xxx) which is rtd->dev.
This means, if rtd->dev was freed, rtd will be also freed automatically.
soc_new_pcm_runtime(...) { ... rtd = devm_kzalloc(dev, ...); rtd->dev = dev; ... }
This explanation was missing at soc_free_pcm_runtime() comment. This patch indicates it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-core.c | 8 ++++++++ 1 file changed, 8 insertions(+)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 4d7e0d8f7269..e71aa1c92e66 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -413,6 +413,14 @@ static void soc_free_pcm_runtime(struct snd_soc_pcm_runtime *rtd) * it is alloced *before* rtd. * see * soc_new_pcm_runtime() + * + * We don't need to mind freeing for rtd, + * because it was created from dev (= rtd->dev) + * see + * soc_new_pcm_runtime() + * + * rtd = devm_kzalloc(dev, ...); + * rtd->dev = dev */ device_unregister(rtd->dev); }
From: Kuninori Morimoto kuninori.morimoto.gx@renesas.com
Because soc_free_pcm_runtime(rtd) checks rtd pointer and freeing rtd->xxx, it doesn't work correctly in case of rtd allocation failed.
We need to use device_unregister(dev) in such case. This patch fixup it.
Signed-off-by: Kuninori Morimoto kuninori.morimoto.gx@renesas.com --- sound/soc/soc-core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index e71aa1c92e66..92d1d9240d4d 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -470,8 +470,10 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime( dai_link->num_codecs + dai_link->num_platforms), GFP_KERNEL); - if (!rtd) - goto free_rtd; + if (!rtd) { + device_unregister(dev); + return NULL; + }
rtd->dev = dev; INIT_LIST_HEAD(&rtd->list);
On 30 Mar 2021 14:25:52 +0900, Kuninori Morimoto wrote:
These are small clanup patches for soc-core. [1/2] patch adds missing explanation, and [2/2] patch fixup error handling of rtd.
Kuninori Morimoto (2): ASoC: soc-core: add comment for rtd freeing ASoC: soc-core: use device_unregister() if rtd allocation failed
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/2] ASoC: soc-core: add comment for rtd freeing commit: f1b3ee789f4b7a41ad93ff42d4efbae607622ae7 [2/2] ASoC: soc-core: use device_unregister() if rtd allocation failed commit: 5fa7553dcd83c576c589fd3e617dc599e4fe15dc
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks, Mark
participants (2)
-
Kuninori Morimoto
-
Mark Brown