<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jun 14, 2023 at 8:15 PM Claudiu Beznea <<a href="mailto:claudiu.beznea@microchip.com">claudiu.beznea@microchip.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">devm_kasprintf() returns a pointer to dynamically allocated memory.<br>
Pointer could be NULL in case allocation fails. Check pointer validity.<br>
Identified with coccinelle (kmerr.cocci script).<br>
<br>
Fixes: b86ef5367761 ("ASoC: fsl: Add Audio Mixer machine driver")<br>
Signed-off-by: Claudiu Beznea <<a href="mailto:claudiu.beznea@microchip.com" target="_blank">claudiu.beznea@microchip.com</a>><br></blockquote><div><br></div><div>Acked-by: Shengjiu Wang <<a href="mailto:shengjiu.wang@gmail.com">shengjiu.wang@gmail.com</a>></div><div><br></div><div>Best regards</div><div>Wang shengjiu </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
---<br>
<br>
Hi,<br>
<br>
This has been addressed using kmerr.cocci script proposed for update<br>
at [1].<br>
<br>
Thank you,<br>
Claudiu Beznea<br>
<br>
[1] <a href="https://lore.kernel.org/all/20230530074044.1603426-1-claudiu.beznea@microchip.com/" rel="noreferrer" target="_blank">https://lore.kernel.org/all/20230530074044.1603426-1-claudiu.beznea@microchip.com/</a><br>
<br>
sound/soc/fsl/imx-audmix.c | 9 +++++++++<br>
1 file changed, 9 insertions(+)<br>
<br>
diff --git a/sound/soc/fsl/imx-audmix.c b/sound/soc/fsl/imx-audmix.c<br>
index 2c57fe9d2d08..af06268ee57b 100644<br>
--- a/sound/soc/fsl/imx-audmix.c<br>
+++ b/sound/soc/fsl/imx-audmix.c<br>
@@ -228,6 +228,8 @@ static int imx_audmix_probe(struct platform_device *pdev)<br>
<br>
dai_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s%s",<br>
fe_name_pref, args.np->full_name + 1);<br>
+ if (!dai_name)<br>
+ return -ENOMEM;<br>
<br>
dev_info(pdev->dev.parent, "DAI FE name:%s\n", dai_name);<br>
<br>
@@ -236,6 +238,8 @@ static int imx_audmix_probe(struct platform_device *pdev)<br>
capture_dai_name =<br>
devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s %s",<br>
dai_name, "CPU-Capture");<br>
+ if (!capture_dai_name)<br>
+ return -ENOMEM;<br>
}<br>
<br>
priv->dai[i].cpus = &dlc[0];<br>
@@ -263,6 +267,8 @@ static int imx_audmix_probe(struct platform_device *pdev)<br>
"AUDMIX-Playback-%d", i);<br>
be_cp = devm_kasprintf(&pdev->dev, GFP_KERNEL,<br>
"AUDMIX-Capture-%d", i);<br>
+ if (!be_name || !be_pb || !be_cp)<br>
+ return -ENOMEM;<br>
<br>
priv->dai[num_dai + i].cpus = &dlc[2];<br>
priv->dai[num_dai + i].codecs = &dlc[3];<br>
@@ -287,6 +293,9 @@ static int imx_audmix_probe(struct platform_device *pdev)<br>
priv->dapm_routes[i].source =<br>
devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s %s",<br>
dai_name, "CPU-Playback");<br>
+ if (!priv->dapm_routes[i].source)<br>
+ return -ENOMEM;<br>
+<br>
priv->dapm_routes[i].sink = be_pb;<br>
priv->dapm_routes[num_dai + i].source = be_pb;<br>
priv->dapm_routes[num_dai + i].sink = be_cp;<br>
-- <br>
2.34.1<br>
<br>
</blockquote></div></div>