RE: [PATCH 08/17] ASoC: sti: sti_uniperif: add missing error check

2021-03-29 Thread Arnaud POULIQUEN



> -Original Message-
> From: Pierre-Louis Bossart 
> Sent: vendredi 26 mars 2021 22:59
> To: alsa-de...@alsa-project.org
> Cc: ti...@suse.de; broo...@kernel.org; linux-kernel@vger.kernel.org; Pierre-
> Louis Bossart ; Arnaud POULIQUEN
> ; Liam Girdwood ;
> Jaroslav Kysela ; Takashi Iwai 
> Subject: [PATCH 08/17] ASoC: sti: sti_uniperif: add missing error check
> 
> cppcheck warning:
> 
> sound/soc/sti/sti_uniperif.c:490:6: style: Variable 'ret' is reassigned a 
> value
> before the old one has been used. [redundantAssignment]  ret =
> devm_snd_soc_register_component(>dev,
>  ^
> sound/soc/sti/sti_uniperif.c:486:6: note: ret is assigned  ret =
> sti_uniperiph_cpu_dai_of(node, priv);
>  ^
> sound/soc/sti/sti_uniperif.c:490:6: note: ret is overwritten  ret =
> devm_snd_soc_register_component(>dev,
>  ^
> 
> sti_uniperiph_cpu_dai_of() can return -EINVAL which seems like a good-enough
> reason to bail.
> 
> Signed-off-by: Pierre-Louis Bossart 

Reviewed-by: Arnaud Pouliquen 

Thanks
Arnaud

> ---
>  sound/soc/sti/sti_uniperif.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/sound/soc/sti/sti_uniperif.c b/sound/soc/sti/sti_uniperif.c index
> 7b9169f04d6e..67315d9b352d 100644
> --- a/sound/soc/sti/sti_uniperif.c
> +++ b/sound/soc/sti/sti_uniperif.c
> @@ -484,6 +484,8 @@ static int sti_uniperiph_probe(struct platform_device
> *pdev)
>   priv->pdev = pdev;
> 
>   ret = sti_uniperiph_cpu_dai_of(node, priv);
> + if (ret < 0)
> + return ret;
> 
>   dev_set_drvdata(>dev, priv);
> 
> --
> 2.25.1



[PATCH 08/17] ASoC: sti: sti_uniperif: add missing error check

2021-03-26 Thread Pierre-Louis Bossart
cppcheck warning:

sound/soc/sti/sti_uniperif.c:490:6: style: Variable 'ret' is
reassigned a value before the old one has been
used. [redundantAssignment]
 ret = devm_snd_soc_register_component(>dev,
 ^
sound/soc/sti/sti_uniperif.c:486:6: note: ret is assigned
 ret = sti_uniperiph_cpu_dai_of(node, priv);
 ^
sound/soc/sti/sti_uniperif.c:490:6: note: ret is overwritten
 ret = devm_snd_soc_register_component(>dev,
 ^

sti_uniperiph_cpu_dai_of() can return -EINVAL which seems like a
good-enough reason to bail.

Signed-off-by: Pierre-Louis Bossart 
---
 sound/soc/sti/sti_uniperif.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/sound/soc/sti/sti_uniperif.c b/sound/soc/sti/sti_uniperif.c
index 7b9169f04d6e..67315d9b352d 100644
--- a/sound/soc/sti/sti_uniperif.c
+++ b/sound/soc/sti/sti_uniperif.c
@@ -484,6 +484,8 @@ static int sti_uniperiph_probe(struct platform_device *pdev)
priv->pdev = pdev;
 
ret = sti_uniperiph_cpu_dai_of(node, priv);
+   if (ret < 0)
+   return ret;
 
dev_set_drvdata(>dev, priv);
 
-- 
2.25.1