Commit 2f76e1d6 authored by Claudiu Beznea's avatar Claudiu Beznea Committed by Mark Brown

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

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: b86ef536 ("ASoC: fsl: Add Audio Mixer machine driver")
Signed-off-by: default avatarClaudiu Beznea <claudiu.beznea@microchip.com>
Link: https://lore.kernel.org/r/20230614121509.443926-1-claudiu.beznea@microchip.comSigned-off-by: default avatarMark Brown <broonie@kernel.org>
parent 997905d5
...@@ -227,6 +227,8 @@ static int imx_audmix_probe(struct platform_device *pdev) ...@@ -227,6 +227,8 @@ static int imx_audmix_probe(struct platform_device *pdev)
dai_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s%s", dai_name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s%s",
fe_name_pref, args.np->full_name + 1); 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); dev_info(pdev->dev.parent, "DAI FE name:%s\n", dai_name);
...@@ -235,6 +237,8 @@ static int imx_audmix_probe(struct platform_device *pdev) ...@@ -235,6 +237,8 @@ static int imx_audmix_probe(struct platform_device *pdev)
capture_dai_name = capture_dai_name =
devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s %s", devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s %s",
dai_name, "CPU-Capture"); dai_name, "CPU-Capture");
if (!capture_dai_name)
return -ENOMEM;
} }
/* /*
...@@ -266,6 +270,8 @@ static int imx_audmix_probe(struct platform_device *pdev) ...@@ -266,6 +270,8 @@ static int imx_audmix_probe(struct platform_device *pdev)
"AUDMIX-Playback-%d", i); "AUDMIX-Playback-%d", i);
be_cp = devm_kasprintf(&pdev->dev, GFP_KERNEL, be_cp = devm_kasprintf(&pdev->dev, GFP_KERNEL,
"AUDMIX-Capture-%d", i); "AUDMIX-Capture-%d", i);
if (!be_name || !be_pb || !be_cp)
return -ENOMEM;
priv->dai[num_dai + i].cpus = &dlc[1]; priv->dai[num_dai + i].cpus = &dlc[1];
priv->dai[num_dai + i].codecs = &asoc_dummy_dlc; priv->dai[num_dai + i].codecs = &asoc_dummy_dlc;
...@@ -288,6 +294,9 @@ static int imx_audmix_probe(struct platform_device *pdev) ...@@ -288,6 +294,9 @@ static int imx_audmix_probe(struct platform_device *pdev)
priv->dapm_routes[i].source = priv->dapm_routes[i].source =
devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s %s", devm_kasprintf(&pdev->dev, GFP_KERNEL, "%s %s",
dai_name, "CPU-Playback"); dai_name, "CPU-Playback");
if (!priv->dapm_routes[i].source)
return -ENOMEM;
priv->dapm_routes[i].sink = be_pb; priv->dapm_routes[i].sink = be_pb;
priv->dapm_routes[num_dai + i].source = be_pb; priv->dapm_routes[num_dai + i].source = be_pb;
priv->dapm_routes[num_dai + i].sink = be_cp; priv->dapm_routes[num_dai + i].sink = be_cp;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment