Linux Sound subsystem development
 help / color / mirror / Atom feed
From: Cezary Rojewski <cezary.rojewski@intel.com>
To: broonie@kernel.org
Cc: tiwai@suse.com, perex@perex.cz,
	amadeuszx.slawinski@linux.intel.com, linux-sound@vger.kernel.org,
	Cezary Rojewski <cezary.rojewski@intel.com>
Subject: [PATCH 4/9] ASoC: Intel: avs: Fix possible null-ptr-deref when initing hw
Date: Fri, 30 May 2025 16:10:20 +0200	[thread overview]
Message-ID: <20250530141025.2942936-5-cezary.rojewski@intel.com> (raw)
In-Reply-To: <20250530141025.2942936-1-cezary.rojewski@intel.com>

Search result of avs_dai_find_path_template() shall be verified before
being used. As 'template' is already known when
avs_hw_constraints_init() is fired, drop the search entirely.

Fixes: f2f847461fb7 ("ASoC: Intel: avs: Constrain path based on BE capabilities")
Reviewed-by: Amadeusz Sławiński <amadeuszx.slawinski@linux.intel.com>
Signed-off-by: Cezary Rojewski <cezary.rojewski@intel.com>
---
 sound/soc/intel/avs/pcm.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/sound/soc/intel/avs/pcm.c b/sound/soc/intel/avs/pcm.c
index d1acc636add7..ccf90428126d 100644
--- a/sound/soc/intel/avs/pcm.c
+++ b/sound/soc/intel/avs/pcm.c
@@ -83,10 +83,8 @@ void avs_period_elapsed(struct snd_pcm_substream *substream)
 static int hw_rule_param_size(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule);
 static int avs_hw_constraints_init(struct snd_pcm_substream *substream, struct snd_soc_dai *dai)
 {
-	struct snd_soc_pcm_runtime *rtd = snd_soc_substream_to_rtd(substream);
 	struct snd_pcm_runtime *runtime = substream->runtime;
 	struct snd_pcm_hw_constraint_list *r, *c, *s;
-	struct avs_tplg_path_template *template;
 	struct avs_dma_data *data;
 	int ret;
 
@@ -99,8 +97,7 @@ static int avs_hw_constraints_init(struct snd_pcm_substream *substream, struct s
 	c = &(data->channels_list);
 	s = &(data->sample_bits_list);
 
-	template = avs_dai_find_path_template(dai, !rtd->dai_link->no_pcm, substream->stream);
-	ret = avs_path_set_constraint(data->adev, template, r, c, s);
+	ret = avs_path_set_constraint(data->adev, data->template, r, c, s);
 	if (ret <= 0)
 		return ret;
 
-- 
2.25.1


  parent reply	other threads:[~2025-05-30 13:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-30 14:10 [PATCH 0/9] ASoC: Intel: avs: Set of functional fixes Cezary Rojewski
2025-05-30 14:10 ` [PATCH 1/9] ASoC: codecs: hda: Fix RPM usage count underflow Cezary Rojewski
2025-05-30 14:10 ` [PATCH 2/9] ASoC: Intel: avs: Fix deadlock when the failing IPC is SET_D0IX Cezary Rojewski
2025-05-30 14:10 ` [PATCH 3/9] ASoC: Intel: avs: Fix PPLCxFMT calculation Cezary Rojewski
2025-05-30 14:10 ` Cezary Rojewski [this message]
2025-05-30 14:10 ` [PATCH 5/9] ASoC: Intel: avs: Fix paths in MODULE_FIRMWARE hints Cezary Rojewski
2025-05-30 14:10 ` [PATCH 6/9] ASoC: Intel: avs: Verify kcalloc() status when setting constraints Cezary Rojewski
2025-05-30 14:10 ` [PATCH 7/9] ASoC: Intel: avs: Verify content returned by parse_int_array() Cezary Rojewski
2025-05-30 14:10 ` [PATCH 8/9] ASoC: Intel: avs: Simplify verification of parse_int_array() result Cezary Rojewski
2025-05-30 14:10 ` [PATCH 9/9] ASoC: Intel: avs: Include missing string.h Cezary Rojewski
2025-06-02 16:42 ` (subset) [PATCH 0/9] ASoC: Intel: avs: Set of functional fixes Mark Brown
2025-06-03 10:57   ` Cezary Rojewski
2025-06-03 11:01     ` Mark Brown
2025-06-03 11:03       ` Cezary Rojewski
2025-06-03 16: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=20250530141025.2942936-5-cezary.rojewski@intel.com \
    --to=cezary.rojewski@intel.com \
    --cc=amadeuszx.slawinski@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.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