linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Shengjiu Wang <shengjiu.wang@gmail.com>
To: Claudiu Beznea <claudiu.beznea@microchip.com>
Cc: alsa-devel@alsa-project.org, linuxppc-dev@lists.ozlabs.org,
	linux-kernel@vger.kernel.org, viorel.suman@nxp.com,
	Xiubo.Lee@gmail.com, shawnguo@kernel.org, s.hauer@pengutronix.de,
	tiwai@suse.com, lgirdwood@gmail.com, perex@perex.cz,
	nicoleotsuka@gmail.com, broonie@kernel.org, linux-imx@nxp.com,
	kernel@pengutronix.de, festevam@gmail.com,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] ASoC: imx-audmix: check return value of devm_kasprintf()
Date: Mon, 19 Jun 2023 10:14:33 +0800	[thread overview]
Message-ID: <CAA+D8APLC5jk2jFmeT6HEP84Hr8XdL5gqiopZDUrz0sSB+7JOw@mail.gmail.com> (raw)
In-Reply-To: <20230614121509.443926-1-claudiu.beznea@microchip.com>

[-- Attachment #1: Type: text/plain, Size: 2990 bytes --]

On Wed, Jun 14, 2023 at 8:15 PM Claudiu Beznea <claudiu.beznea@microchip.com>
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 <claudiu.beznea@microchip.com>
>

Acked-by: Shengjiu Wang <shengjiu.wang@gmail.com>

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.beznea@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(&pdev->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(&pdev->dev, GFP_KERNEL, "%s
> %s",
>                                                dai_name, "CPU-Capture");
> +                       if (!capture_dai_name)
> +                               return -ENOMEM;
>                 }
>
>                 priv->dai[i].cpus = &dlc[0];
> @@ -263,6 +267,8 @@ static int imx_audmix_probe(struct platform_device
> *pdev)
>                                        "AUDMIX-Playback-%d", i);
>                 be_cp = devm_kasprintf(&pdev->dev, GFP_KERNEL,
>                                        "AUDMIX-Capture-%d", i);
> +               if (!be_name || !be_pb || !be_cp)
> +                       return -ENOMEM;
>
>                 priv->dai[num_dai + i].cpus = &dlc[2];
>                 priv->dai[num_dai + i].codecs = &dlc[3];
> @@ -287,6 +293,9 @@ static int imx_audmix_probe(struct platform_device
> *pdev)
>                 priv->dapm_routes[i].source =
>                         devm_kasprintf(&pdev->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
>
>

[-- Attachment #2: Type: text/html, Size: 4347 bytes --]

  reply	other threads:[~2023-06-19  2:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-14 12:15 [PATCH] ASoC: imx-audmix: check return value of devm_kasprintf() Claudiu Beznea
2023-06-19  2:14 ` Shengjiu Wang [this message]
2023-06-19 22:29 ` Mark Brown

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAA+D8APLC5jk2jFmeT6HEP84Hr8XdL5gqiopZDUrz0sSB+7JOw@mail.gmail.com \
    --to=shengjiu.wang@gmail.com \
    --cc=Xiubo.Lee@gmail.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=claudiu.beznea@microchip.com \
    --cc=festevam@gmail.com \
    --cc=kernel@pengutronix.de \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=nicoleotsuka@gmail.com \
    --cc=perex@perex.cz \
    --cc=s.hauer@pengutronix.de \
    --cc=shawnguo@kernel.org \
    --cc=tiwai@suse.com \
    --cc=viorel.suman@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).