Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Henry Martin <bsdhenrymartin@gmail.com>
To: cezary.rojewski@intel.com, liam.r.girdwood@linux.intel.com,
	peter.ujfalusi@linux.intel.com, yung-chuan.liao@linux.intel.com,
	ranjani.sridharan@linux.intel.com, kai.vehmanen@linux.intel.com
Cc: pierre-louis.bossart@linux.dev, broonie@kernel.org,
	perex@perex.cz, tiwai@suse.com,
	amadeuszx.slawinski@linux.intel.com, ethan@ethancedwards.com,
	jbrunet@baylibre.com, bsdhenrymartin@gmail.com,
	linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v2] ASoC: Intel: avs: Fix null-ptr-deref in avs_component_probe()
Date: Wed,  2 Apr 2025 22:14:11 +0800	[thread overview]
Message-ID: <20250402141411.44972-1-bsdhenrymartin@gmail.com> (raw)
In-Reply-To: <95c39d93-f35f-4017-843e-e5d836f1b091@intel.com>

devm_kasprintf() returns NULL when memory allocation fails. Currently,
avs_component_probe() does not check for this case, which results in a
NULL pointer dereference.

Fixes: 739c031110da ("ASoC: Intel: avs: Provide support for fallback topology")
Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com>
Reviewed-by: Ethan Carter Edwards <ethan@ethancedwards.com>
Signed-off-by: Henry Martin <bsdhenrymartin@gmail.com>
---
V1 -> V2: No functional changes, just correct title and redundant commit
message.

 sound/soc/intel/avs/pcm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/soc/intel/avs/pcm.c b/sound/soc/intel/avs/pcm.c
index dac463390da1..7072bcf4e56f 100644
--- a/sound/soc/intel/avs/pcm.c
+++ b/sound/soc/intel/avs/pcm.c
@@ -927,7 +927,8 @@ static int avs_component_probe(struct snd_soc_component *component)
 		else
 			mach->tplg_filename = devm_kasprintf(adev->dev, GFP_KERNEL,
 							     "hda-generic-tplg.bin");
-
+		if (!mach->tplg_filename)
+			return -ENOMEM;
 		filename = kasprintf(GFP_KERNEL, "%s/%s", component->driver->topology_name_prefix,
 				     mach->tplg_filename);
 		if (!filename)
-- 
2.34.1


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

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-01 14:32 [PATCH v1] ASoC: Intel: avs: Add NULL check in avs_component_probe() Henry Martin
2025-04-02 12:00 ` [PATCH] " Markus Elfring
2025-04-02 13:34   ` Ethan Carter Edwards
2025-04-02 14:42     ` Markus Elfring
2025-04-02 14:14   ` [PATCH] " Mark Brown
2025-04-02 13:59 ` [PATCH v1] " Cezary Rojewski
2025-04-02 14:14   ` Henry Martin [this message]
2025-04-02 19:18     ` [PATCH v2] ASoC: Intel: avs: Fix null-ptr-deref " Markus Elfring
2025-04-02 19:56       ` Mark Brown
2025-04-07 23:48     ` 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=20250402141411.44972-1-bsdhenrymartin@gmail.com \
    --to=bsdhenrymartin@gmail.com \
    --cc=amadeuszx.slawinski@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=cezary.rojewski@intel.com \
    --cc=ethan@ethancedwards.com \
    --cc=jbrunet@baylibre.com \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=liam.r.girdwood@linux.intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=peter.ujfalusi@linux.intel.com \
    --cc=pierre-louis.bossart@linux.dev \
    --cc=ranjani.sridharan@linux.intel.com \
    --cc=tiwai@suse.com \
    --cc=yung-chuan.liao@linux.intel.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