diff mbox series

ASoC: imx-audmix: Add NULL check in imx_audmix_probe

Message ID 20241115065610.39112-1-hanchunchao@inspur.com (mailing list archive)
State Superseded
Headers show
Series ASoC: imx-audmix: Add NULL check in imx_audmix_probe | expand

Commit Message

Charles Han Nov. 15, 2024, 6:56 a.m. UTC
devm_kasprintf() can return a NULL pointer on failure,but this
returned value in imx_audmix_probe() is not checked.
Add NULL check in imx_audmix_probe(), to handle kernel NULL
pointer dereference error.

Fixes: b86ef5367761 ("ASoC: fsl: Add Audio Mixer machine driver")
Signed-off-by: Charles Han <hanchunchao@inspur.com>
---
 sound/soc/fsl/imx-audmix.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Shengjiu Wang Nov. 15, 2024, 7:03 a.m. UTC | #1
On Fri, Nov 15, 2024 at 2:56 PM Charles Han <hanchunchao@inspur.com> wrote:
>
> devm_kasprintf() can return a NULL pointer on failure,but this
> returned value in imx_audmix_probe() is not checked.
> Add NULL check in imx_audmix_probe(), to handle kernel NULL
> pointer dereference error.
>
> Fixes: b86ef5367761 ("ASoC: fsl: Add Audio Mixer machine driver")

The fixes tag should be:
05d996e11348 ("ASoC: imx-audmix: Split capture device for audmix")

Best regards
Shengjiu Wang

> Signed-off-by: Charles Han <hanchunchao@inspur.com>
> ---
>  sound/soc/fsl/imx-audmix.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/sound/soc/fsl/imx-audmix.c b/sound/soc/fsl/imx-audmix.c
> index dcf770b55c4b..231400661c90 100644
> --- a/sound/soc/fsl/imx-audmix.c
> +++ b/sound/soc/fsl/imx-audmix.c
> @@ -274,6 +274,9 @@ static int imx_audmix_probe(struct platform_device *pdev)
>                 /* Add AUDMIX Backend */
>                 be_name = devm_kasprintf(&pdev->dev, GFP_KERNEL,
>                                          "audmix-%d", i);
> +               if (!be_name)
> +                       return -ENOMEM;
> +
>                 priv->dai[num_dai + i].cpus     = &dlc[1];
>                 priv->dai[num_dai + i].codecs   = &snd_soc_dummy_dlc;
>
> --
> 2.31.1
>
diff mbox series

Patch

diff --git a/sound/soc/fsl/imx-audmix.c b/sound/soc/fsl/imx-audmix.c
index dcf770b55c4b..231400661c90 100644
--- a/sound/soc/fsl/imx-audmix.c
+++ b/sound/soc/fsl/imx-audmix.c
@@ -274,6 +274,9 @@  static int imx_audmix_probe(struct platform_device *pdev)
 		/* Add AUDMIX Backend */
 		be_name = devm_kasprintf(&pdev->dev, GFP_KERNEL,
 					 "audmix-%d", i);
+		if (!be_name)
+			return -ENOMEM;
+
 		priv->dai[num_dai + i].cpus	= &dlc[1];
 		priv->dai[num_dai + i].codecs	= &snd_soc_dummy_dlc;