All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: alsa-devel@alsa-project.org
Cc: "Weiguo Li" <liwg06@foxmail.com>,
	tiwai@suse.de, "Péter Ujfalusi" <peter.ujfalusi@linux.intel.com>,
	"Ranjani Sridharan" <ranjani.sridharan@linux.intel.com>,
	"Pierre-Louis Bossart" <pierre-louis.bossart@linux.intel.com>,
	broonie@kernel.org, "Daniel Baluta" <daniel.baluta@nxp.com>
Subject: [PATCH 2/5] ASoC: SOF: compress: fix null check after dereference
Date: Thu, 10 Mar 2022 11:16:48 -0600	[thread overview]
Message-ID: <20220310171651.249385-3-pierre-louis.bossart@linux.intel.com> (raw)
In-Reply-To: <20220310171651.249385-1-pierre-louis.bossart@linux.intel.com>

From: Weiguo Li <liwg06@foxmail.com>

"cstream" is dereferenced but null checked later. Swap their
positions to avoid potential null dereference.

Reviewed-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>
Reviewed-by: Péter Ujfalusi <peter.ujfalusi@linux.intel.com>
Signed-off-by: Weiguo Li <liwg06@foxmail.com>
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
 sound/soc/sof/compress.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/sound/soc/sof/compress.c b/sound/soc/sof/compress.c
index 2af8d75204e9..a8e908e50101 100644
--- a/sound/soc/sof/compress.c
+++ b/sound/soc/sof/compress.c
@@ -46,8 +46,8 @@ void snd_sof_compr_init_elapsed_work(struct work_struct *work)
  */
 void snd_sof_compr_fragment_elapsed(struct snd_compr_stream *cstream)
 {
-	struct snd_soc_pcm_runtime *rtd = cstream->private_data;
-	struct snd_compr_runtime *crtd = cstream->runtime;
+	struct snd_soc_pcm_runtime *rtd;
+	struct snd_compr_runtime *crtd;
 	struct snd_soc_component *component;
 	struct snd_compr_tstamp *tstamp;
 	struct snd_sof_pcm *spcm;
@@ -55,6 +55,8 @@ void snd_sof_compr_fragment_elapsed(struct snd_compr_stream *cstream)
 	if (!cstream)
 		return;
 
+	rtd = cstream->private_data;
+	crtd = cstream->runtime;
 	tstamp = crtd->private_data;
 	component = snd_soc_rtdcom_lookup(rtd, SOF_AUDIO_PCM_DRV_NAME);
 
-- 
2.30.2


  parent reply	other threads:[~2022-03-10 17:25 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-10 17:16 [PATCH 0/5] ASoC: SOF/Intel: small fixes and updates for 5.18 Pierre-Louis Bossart
2022-03-10 17:16 ` [PATCH 1/5] ASoC: SOF: Intel: enable DMI L1 for playback streams Pierre-Louis Bossart
2022-03-10 17:16 ` Pierre-Louis Bossart [this message]
2022-03-10 17:16 ` [PATCH 3/5] ASoC: SOF: trace: Use proper DMA direction for the trace data buffer Pierre-Louis Bossart
2022-03-10 17:16 ` [PATCH 4/5] ASoC: SOF: Intel: add topology overwrite for Taniks Pierre-Louis Bossart
2022-03-10 17:16 ` [PATCH 5/5] ASoC: Intel: soc-acpi: Add entry for rt711-sdca-sdw in ADL match table Pierre-Louis Bossart
2022-03-11 20:22 ` [PATCH 0/5] ASoC: SOF/Intel: small fixes and updates for 5.18 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=20220310171651.249385-3-pierre-louis.bossart@linux.intel.com \
    --to=pierre-louis.bossart@linux.intel.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=daniel.baluta@nxp.com \
    --cc=liwg06@foxmail.com \
    --cc=peter.ujfalusi@linux.intel.com \
    --cc=ranjani.sridharan@linux.intel.com \
    --cc=tiwai@suse.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.