mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@nxp.com>
To: Henry Martin <bsdhenrymartin@gmail.com>
Cc: shengjiu.wang@gmail.com, xiubo.lee@gmail.com, festevam@gmail.com,
	nicoleotsuka@gmail.com, lgirdwood@gmail.com, broonie@kernel.org,
	perex@perex.cz, tiwai@suse.com, shawnguo@kernel.org,
	s.hauer@pengutronix.de, kernel@pengutronix.de,
	linux-sound@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
	imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1] ASoC: imx-card: Add NULL check in imx_card_probe()
Date: Tue, 1 Apr 2025 10:52:25 -0400	[thread overview]
Message-ID: <Z+v9qbFjSNpDcHW1@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20250401142510.29900-1-bsdhenrymartin@gmail.com>

On Tue, Apr 01, 2025 at 10:25:10PM +0800, Henry Martin wrote:
> devm_kasprintf() returns NULL when memory allocation fails. Currently,
> imx_card_probe() does not check for this case, which results in a NULL
> pointer dereference.
>
> Add NULL check after devm_kasprintf() to prevent this issue.
>
> Fixes: aa736700f42f ("ASoC: imx-card: Add imx-card machine driver")
> Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
> ---

Reviewed-by: Frank Li <Frank.Li@nxp.com>

>  sound/soc/fsl/imx-card.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/sound/soc/fsl/imx-card.c b/sound/soc/fsl/imx-card.c
> index 905294682996..3686d468506b 100644
> --- a/sound/soc/fsl/imx-card.c
> +++ b/sound/soc/fsl/imx-card.c
> @@ -772,6 +772,8 @@ static int imx_card_probe(struct platform_device *pdev)
>  				data->dapm_routes[i].sink =
>  					devm_kasprintf(&pdev->dev, GFP_KERNEL, "%d %s",
>  						       i + 1, "Playback");
> +				if (!data->dapm_routes[i].sink)
> +					return -ENOMEM;
>  				data->dapm_routes[i].source = "CPU-Playback";
>  			}
>  		}
> @@ -789,6 +791,8 @@ static int imx_card_probe(struct platform_device *pdev)
>  				data->dapm_routes[i].source =
>  					devm_kasprintf(&pdev->dev, GFP_KERNEL, "%d %s",
>  						       i + 1, "Capture");
> +				if (!data->dapm_routes[i].source)
> +					return -ENOMEM;
>  				data->dapm_routes[i].sink = "CPU-Capture";
>  			}
>  		}
> --
> 2.34.1
>

  reply	other threads:[~2025-04-01 14:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-01 14:25 Henry Martin
2025-04-01 14:52 ` Frank Li [this message]
2025-04-01 18:04 ` 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=Z+v9qbFjSNpDcHW1@lizhi-Precision-Tower-5810 \
    --to=frank.li@nxp.com \
    --cc=broonie@kernel.org \
    --cc=bsdhenrymartin@gmail.com \
    --cc=festevam@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=kernel@pengutronix.de \
    --cc=lgirdwood@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@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=shengjiu.wang@gmail.com \
    --cc=tiwai@suse.com \
    --cc=xiubo.lee@gmail.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

all inboxes | Powered by JetHome®