Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Cezary Rojewski <cezary.rojewski@intel.com>
To: Guangshuo Li <lgs201920130244@gmail.com>
Cc: stable@vger.kernel.org,
	"Liam Girdwood" <liam.r.girdwood@linux.intel.com>,
	"Peter Ujfalusi" <peter.ujfalusi@linux.intel.com>,
	"Bard Liao" <yung-chuan.liao@linux.intel.com>,
	"Ranjani Sridharan" <ranjani.sridharan@linux.intel.com>,
	"Kai Vehmanen" <kai.vehmanen@linux.intel.com>,
	"Pierre-Louis Bossart" <pierre-louis.bossart@linux.dev>,
	"Mark Brown" <broonie@kernel.org>,
	"Jaroslav Kysela" <perex@perex.cz>,
	"Takashi Iwai" <tiwai@suse.com>,
	"Amadeusz Sławiński" <amadeuszx.slawinski@linux.intel.com>,
	"Piotr Maziarz" <piotrx.maziarz@linux.intel.com>,
	linux-sound@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ASoC: Intel: avs: Add check for kcalloc() when setting constraints
Date: Thu, 18 Sep 2025 16:11:34 +0200	[thread overview]
Message-ID: <c595f1a8-373a-42e7-ac22-9a203de05ca7@intel.com> (raw)
In-Reply-To: <20250918135627.3576836-1-lgs201920130244@gmail.com>

On 2025-09-18 3:56 PM, Guangshuo Li wrote:
> kcalloc() may fail. avs_path_set_constraint() writes to rlist[i],
> clist[i], and slist[i] unconditionally, which can cause a NULL pointer
> dereference under low-memory conditions.
> 
> Add checks for the three kcalloc() calls. If any allocation fails,
> free any previously allocated lists and return -ENOMEM.
> 
> Fixes: f2f847461fb7 ("ASoC: Intel: avs: Constrain path based on BE capabilities")
> Cc: stable@vger.kernel.org
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
> ---
>   sound/soc/intel/avs/path.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/sound/soc/intel/avs/path.c b/sound/soc/intel/avs/path.c
> index cafb8c6198be..cb641d37d565 100644
> --- a/sound/soc/intel/avs/path.c
> +++ b/sound/soc/intel/avs/path.c
> @@ -135,6 +135,9 @@ int avs_path_set_constraint(struct avs_dev *adev, struct avs_tplg_path_template
>   	clist = kcalloc(i, sizeof(clist), GFP_KERNEL);
>   	slist = kcalloc(i, sizeof(slist), GFP_KERNEL);
>   
> +	if (!rlist || !clist || !slist)
> +		return -ENOMEM;
> +
>   	i = 0;
>   	list_for_each_entry(path_template, &template->path_list, node) {
>   		struct avs_tplg_pipeline *pipeline_template;

Hi,

Something isn't right here. The code is supposed to be already there, 
please see one of the series [1] I've sent earlier this year. Perhaps 
you're working with an older version of the kernel?

[1]: 
https://lore.kernel.org/all/20250530141025.2942936-7-cezary.rojewski@intel.com/

Kind regards,
Czarek

      reply	other threads:[~2025-09-18 14:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-18 13:56 [PATCH] ASoC: Intel: avs: Add check for kcalloc() when setting constraints Guangshuo Li
2025-09-18 14:11 ` Cezary Rojewski [this message]

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=c595f1a8-373a-42e7-ac22-9a203de05ca7@intel.com \
    --to=cezary.rojewski@intel.com \
    --cc=amadeuszx.slawinski@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=lgs201920130244@gmail.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=piotrx.maziarz@linux.intel.com \
    --cc=ranjani.sridharan@linux.intel.com \
    --cc=stable@vger.kernel.org \
    --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