* [PATCH] ASoC: da7219: Fix an error handling path in da7219_register_dai_clks()
@ 2022-09-22 19:44 Christophe JAILLET
2022-09-23 9:42 ` Dan Carpenter
2022-09-27 10:34 ` Mark Brown
0 siblings, 2 replies; 3+ messages in thread
From: Christophe JAILLET @ 2022-09-22 19:44 UTC (permalink / raw)
To: Support Opensource, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, Adam Thomson
Cc: linux-kernel, kernel-janitors, Christophe JAILLET, Dan Carpenter,
alsa-devel
If clk_hw_register() fails, the corresponding clk should not be
unregistered.
To handle errors from loops, clean up partial iterations before doing the
goto. So add a clk_hw_unregister().
Then use a while (--i >= 0) loop in the unwind section.
Fixes: 78013a1cf297 ("ASoC: da7219: Fix clock handling around codec level probe")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
See https://lore.kernel.org/all/4fdde55198294a07f04933f7cef937fcb654c901.1624425670.git.christophe.jaillet@wanadoo.fr/
for an incomplete patch sent last year and Dan's comment on it.
---
sound/soc/codecs/da7219.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/sound/soc/codecs/da7219.c b/sound/soc/codecs/da7219.c
index 50ecf30e6136..4746c8700451 100644
--- a/sound/soc/codecs/da7219.c
+++ b/sound/soc/codecs/da7219.c
@@ -2196,6 +2196,7 @@ static int da7219_register_dai_clks(struct snd_soc_component *component)
dai_clk_lookup = clkdev_hw_create(dai_clk_hw, init.name,
"%s", dev_name(dev));
if (!dai_clk_lookup) {
+ clk_hw_unregister(dai_clk_hw);
ret = -ENOMEM;
goto err;
} else {
@@ -2217,12 +2218,12 @@ static int da7219_register_dai_clks(struct snd_soc_component *component)
return 0;
err:
- do {
+ while (--i >= 0) {
if (da7219->dai_clks_lookup[i])
clkdev_drop(da7219->dai_clks_lookup[i]);
clk_hw_unregister(&da7219->dai_clks_hw[i]);
- } while (i-- > 0);
+ }
if (np)
kfree(da7219->clk_hw_data);
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: da7219: Fix an error handling path in da7219_register_dai_clks()
2022-09-22 19:44 [PATCH] ASoC: da7219: Fix an error handling path in da7219_register_dai_clks() Christophe JAILLET
@ 2022-09-23 9:42 ` Dan Carpenter
2022-09-27 10:34 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Dan Carpenter @ 2022-09-23 9:42 UTC (permalink / raw)
To: Christophe JAILLET
Cc: Support Opensource, Liam Girdwood, Mark Brown, Jaroslav Kysela,
Takashi Iwai, Adam Thomson, linux-kernel, kernel-janitors,
alsa-devel
On Thu, Sep 22, 2022 at 09:44:57PM +0200, Christophe JAILLET wrote:
> If clk_hw_register() fails, the corresponding clk should not be
> unregistered.
>
> To handle errors from loops, clean up partial iterations before doing the
> goto. So add a clk_hw_unregister().
> Then use a while (--i >= 0) loop in the unwind section.
>
> Fixes: 78013a1cf297 ("ASoC: da7219: Fix clock handling around codec level probe")
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
> ---
> See https://lore.kernel.org/all/4fdde55198294a07f04933f7cef937fcb654c901.1624425670.git.christophe.jaillet@wanadoo.fr/
> for an incomplete patch sent last year and Dan's comment on it.
Thanks!
Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com>
regards,
dan carpenter
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] ASoC: da7219: Fix an error handling path in da7219_register_dai_clks()
2022-09-22 19:44 [PATCH] ASoC: da7219: Fix an error handling path in da7219_register_dai_clks() Christophe JAILLET
2022-09-23 9:42 ` Dan Carpenter
@ 2022-09-27 10:34 ` Mark Brown
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2022-09-27 10:34 UTC (permalink / raw)
To: Support Opensource, Christophe JAILLET, Adam Thomson,
Takashi Iwai, Liam Girdwood, Jaroslav Kysela
Cc: kernel-janitors, alsa-devel, Dan Carpenter, linux-kernel
On Thu, 22 Sep 2022 21:44:57 +0200, Christophe JAILLET wrote:
> If clk_hw_register() fails, the corresponding clk should not be
> unregistered.
>
> To handle errors from loops, clean up partial iterations before doing the
> goto. So add a clk_hw_unregister().
> Then use a while (--i >= 0) loop in the unwind section.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] ASoC: da7219: Fix an error handling path in da7219_register_dai_clks()
commit: abb4e4349afe7eecdb0499582f1c777031e3a7c8
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-09-27 10:34 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-22 19:44 [PATCH] ASoC: da7219: Fix an error handling path in da7219_register_dai_clks() Christophe JAILLET
2022-09-23 9:42 ` Dan Carpenter
2022-09-27 10:34 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).