Re: [PATCH] ASoC: imx-audmix: check return value of devm_kasprintf()

2023-06-19 Thread Mark Brown
On Wed, 14 Jun 2023 15:15:09 +0300, Claudiu Beznea wrote:
> devm_kasprintf() returns a pointer to dynamically allocated memory.
> Pointer could be NULL in case allocation fails. Check pointer validity.
> Identified with coccinelle (kmerr.cocci script).
> 
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/1] ASoC: imx-audmix: check return value of devm_kasprintf()
  commit: 2f76e1d6ca524a888d29aafe29f2ad2003857971

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



Re: [PATCH] ASoC: imx-audmix: check return value of devm_kasprintf()

2023-06-18 Thread Shengjiu Wang
On Wed, Jun 14, 2023 at 8:15 PM Claudiu Beznea 
wrote:

> devm_kasprintf() returns a pointer to dynamically allocated memory.
> Pointer could be NULL in case allocation fails. Check pointer validity.
> Identified with coccinelle (kmerr.cocci script).
>
> Fixes: b86ef5367761 ("ASoC: fsl: Add Audio Mixer machine driver")
> Signed-off-by: Claudiu Beznea 
>

Acked-by: Shengjiu Wang 

Best regards
Wang shengjiu

> ---
>
> Hi,
>
> This has been addressed using kmerr.cocci script proposed for update
> at [1].
>
> Thank you,
> Claudiu Beznea
>
> [1]
> https://lore.kernel.org/all/20230530074044.1603426-1-claudiu.bez...@microchip.com/
>
>  sound/soc/fsl/imx-audmix.c | 9 +
>  1 file changed, 9 insertions(+)
>
> diff --git a/sound/soc/fsl/imx-audmix.c b/sound/soc/fsl/imx-audmix.c
> index 2c57fe9d2d08..af06268ee57b 100644
> --- a/sound/soc/fsl/imx-audmix.c
> +++ b/sound/soc/fsl/imx-audmix.c
> @@ -228,6 +228,8 @@ static int imx_audmix_probe(struct platform_device
> *pdev)
>
> dai_name = devm_kasprintf(>dev, GFP_KERNEL, "%s%s",
>   fe_name_pref, args.np->full_name
> + 1);
> +   if (!dai_name)
> +   return -ENOMEM;
>
> dev_info(pdev->dev.parent, "DAI FE name:%s\n", dai_name);
>
> @@ -236,6 +238,8 @@ static int imx_audmix_probe(struct platform_device
> *pdev)
> capture_dai_name =
> devm_kasprintf(>dev, GFP_KERNEL, "%s
> %s",
>dai_name, "CPU-Capture");
> +   if (!capture_dai_name)
> +   return -ENOMEM;
> }
>
> priv->dai[i].cpus = [0];
> @@ -263,6 +267,8 @@ static int imx_audmix_probe(struct platform_device
> *pdev)
>"AUDMIX-Playback-%d", i);
> be_cp = devm_kasprintf(>dev, GFP_KERNEL,
>"AUDMIX-Capture-%d", i);
> +   if (!be_name || !be_pb || !be_cp)
> +   return -ENOMEM;
>
> priv->dai[num_dai + i].cpus = [2];
> priv->dai[num_dai + i].codecs = [3];
> @@ -287,6 +293,9 @@ static int imx_audmix_probe(struct platform_device
> *pdev)
> priv->dapm_routes[i].source =
> devm_kasprintf(>dev, GFP_KERNEL, "%s %s",
>dai_name, "CPU-Playback");
> +   if (!priv->dapm_routes[i].source)
> +   return -ENOMEM;
> +
> priv->dapm_routes[i].sink = be_pb;
> priv->dapm_routes[num_dai + i].source   = be_pb;
> priv->dapm_routes[num_dai + i].sink = be_cp;
> --
> 2.34.1
>
>


[PATCH] ASoC: imx-audmix: check return value of devm_kasprintf()

2023-06-14 Thread Claudiu Beznea
devm_kasprintf() returns a pointer to dynamically allocated memory.
Pointer could be NULL in case allocation fails. Check pointer validity.
Identified with coccinelle (kmerr.cocci script).

Fixes: b86ef5367761 ("ASoC: fsl: Add Audio Mixer machine driver")
Signed-off-by: Claudiu Beznea 
---

Hi,

This has been addressed using kmerr.cocci script proposed for update
at [1].

Thank you,
Claudiu Beznea

[1] 
https://lore.kernel.org/all/20230530074044.1603426-1-claudiu.bez...@microchip.com/

 sound/soc/fsl/imx-audmix.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/sound/soc/fsl/imx-audmix.c b/sound/soc/fsl/imx-audmix.c
index 2c57fe9d2d08..af06268ee57b 100644
--- a/sound/soc/fsl/imx-audmix.c
+++ b/sound/soc/fsl/imx-audmix.c
@@ -228,6 +228,8 @@ static int imx_audmix_probe(struct platform_device *pdev)
 
dai_name = devm_kasprintf(>dev, GFP_KERNEL, "%s%s",
  fe_name_pref, args.np->full_name + 1);
+   if (!dai_name)
+   return -ENOMEM;
 
dev_info(pdev->dev.parent, "DAI FE name:%s\n", dai_name);
 
@@ -236,6 +238,8 @@ static int imx_audmix_probe(struct platform_device *pdev)
capture_dai_name =
devm_kasprintf(>dev, GFP_KERNEL, "%s %s",
   dai_name, "CPU-Capture");
+   if (!capture_dai_name)
+   return -ENOMEM;
}
 
priv->dai[i].cpus = [0];
@@ -263,6 +267,8 @@ static int imx_audmix_probe(struct platform_device *pdev)
   "AUDMIX-Playback-%d", i);
be_cp = devm_kasprintf(>dev, GFP_KERNEL,
   "AUDMIX-Capture-%d", i);
+   if (!be_name || !be_pb || !be_cp)
+   return -ENOMEM;
 
priv->dai[num_dai + i].cpus = [2];
priv->dai[num_dai + i].codecs = [3];
@@ -287,6 +293,9 @@ static int imx_audmix_probe(struct platform_device *pdev)
priv->dapm_routes[i].source =
devm_kasprintf(>dev, GFP_KERNEL, "%s %s",
   dai_name, "CPU-Playback");
+   if (!priv->dapm_routes[i].source)
+   return -ENOMEM;
+
priv->dapm_routes[i].sink = be_pb;
priv->dapm_routes[num_dai + i].source   = be_pb;
priv->dapm_routes[num_dai + i].sink = be_cp;
-- 
2.34.1