ASoC: soc-core: tidyup error handling for rtd
cover 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(-)
Signature · 1 line
2.25.1
PATCH 1/2 ASoC: soc-core: add comment for rtd freeing
From: Kuninori Morimoto <[email protected]>
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.
--- sound/soc/soc-core.c | 8 ++++++++ 1 file changed, 8 insertions(+)
sound/soc/soc-core.c +8 -0
@@ -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); }
Signature · 1 line
2.25.1
PATCH 2/2 ASoC: soc-core: use device_unregister() if rtd allocation failed
In reply to Kuninori MorimotoFrom: Kuninori Morimoto <[email protected]>
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.
--- sound/soc/soc-core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
sound/soc/soc-core.c +4 -2
@@ -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);
Signature · 1 line
2.25.1
Mark Brown
maintainerQuoted 9 lines · Kuninori Morimoto
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: usedevice_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: 5fa7553dcd83c576c589fd3e617dc599e4fe15dcAll 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