All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Cc: alsa-devel@alsa-project.org,
	"Kai Vehmanen" <kai.vehmanen@linux.intel.com>,
	kernel-janitors@vger.kernel.org,
	"Bard Liao" <yung-chuan.liao@linux.intel.com>,
	"Péter Ujfalusi" <peter.ujfalusi@linux.intel.com>,
	"Takashi Iwai" <tiwai@suse.com>,
	"Liam Girdwood" <lgirdwood@gmail.com>,
	"Mark Brown" <broonie@kernel.org>,
	"Daniel Baluta" <daniel.baluta@nxp.com>,
	sound-open-firmware@alsa-project.org
Subject: [PATCH 2/2] ASoC: SOF: check for NULL before dereferencing
Date: Fri, 18 Mar 2022 10:13:08 +0300	[thread overview]
Message-ID: <20220318071308.GC29472@kili> (raw)
In-Reply-To: <20220318071233.GB29472@kili>

This code dereferences "dai" before checking whether it can be NULL.

Fixes: 839e484f9e17 ("ASoC: SOF: make struct snd_sof_dai IPC agnostic")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 sound/soc/sof/sof-audio.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c
index 15c36a51f89f..88ddd1e2476d 100644
--- a/sound/soc/sof/sof-audio.c
+++ b/sound/soc/sof/sof-audio.c
@@ -626,10 +626,13 @@ int sof_set_up_pipelines(struct snd_sof_dev *sdev, bool verify)
 		/* update DAI config. The IPC will be sent in sof_widget_setup() */
 		if (WIDGET_IS_DAI(swidget->id)) {
 			struct snd_sof_dai *dai = swidget->private;
-			struct sof_dai_private_data *private = dai->private;
+			struct sof_dai_private_data *private;
 			struct sof_ipc_dai_config *config;
 
-			if (!dai || !private || !private->dai_config)
+			if (!dai)
+				continue;
+			private = dai->private;
+			if (!private || !private->dai_config)
 				continue;
 
 			config = private->dai_config;
@@ -918,10 +921,13 @@ static int sof_dai_get_clk(struct snd_soc_pcm_runtime *rtd, int clk_type)
 		snd_soc_rtdcom_lookup(rtd, SOF_AUDIO_PCM_DRV_NAME);
 	struct snd_sof_dai *dai =
 		snd_sof_find_dai(component, (char *)rtd->dai_link->name);
-	struct sof_dai_private_data *private = dai->private;
+	struct sof_dai_private_data *private;
 
 	/* use the tplg configured mclk if existed */
-	if (!dai || !private || !private->dai_config)
+	if (!dai)
+		return 0;
+	private = dai->private;
+	if (!private || !private->dai_config)
 		return 0;
 
 	switch (private->dai_config->type) {
-- 
2.20.1


WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
	Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Cc: "Liam Girdwood" <lgirdwood@gmail.com>,
	"Kai Vehmanen" <kai.vehmanen@linux.intel.com>,
	"Daniel Baluta" <daniel.baluta@nxp.com>,
	"Mark Brown" <broonie@kernel.org>,
	"Jaroslav Kysela" <perex@perex.cz>,
	"Takashi Iwai" <tiwai@suse.com>,
	"Bard Liao" <yung-chuan.liao@linux.intel.com>,
	"Péter Ujfalusi" <peter.ujfalusi@linux.intel.com>,
	sound-open-firmware@alsa-project.org,
	alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org
Subject: [PATCH 2/2] ASoC: SOF: check for NULL before dereferencing
Date: Fri, 18 Mar 2022 10:13:08 +0300	[thread overview]
Message-ID: <20220318071308.GC29472@kili> (raw)
In-Reply-To: <20220318071233.GB29472@kili>

This code dereferences "dai" before checking whether it can be NULL.

Fixes: 839e484f9e17 ("ASoC: SOF: make struct snd_sof_dai IPC agnostic")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 sound/soc/sof/sof-audio.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/sound/soc/sof/sof-audio.c b/sound/soc/sof/sof-audio.c
index 15c36a51f89f..88ddd1e2476d 100644
--- a/sound/soc/sof/sof-audio.c
+++ b/sound/soc/sof/sof-audio.c
@@ -626,10 +626,13 @@ int sof_set_up_pipelines(struct snd_sof_dev *sdev, bool verify)
 		/* update DAI config. The IPC will be sent in sof_widget_setup() */
 		if (WIDGET_IS_DAI(swidget->id)) {
 			struct snd_sof_dai *dai = swidget->private;
-			struct sof_dai_private_data *private = dai->private;
+			struct sof_dai_private_data *private;
 			struct sof_ipc_dai_config *config;
 
-			if (!dai || !private || !private->dai_config)
+			if (!dai)
+				continue;
+			private = dai->private;
+			if (!private || !private->dai_config)
 				continue;
 
 			config = private->dai_config;
@@ -918,10 +921,13 @@ static int sof_dai_get_clk(struct snd_soc_pcm_runtime *rtd, int clk_type)
 		snd_soc_rtdcom_lookup(rtd, SOF_AUDIO_PCM_DRV_NAME);
 	struct snd_sof_dai *dai =
 		snd_sof_find_dai(component, (char *)rtd->dai_link->name);
-	struct sof_dai_private_data *private = dai->private;
+	struct sof_dai_private_data *private;
 
 	/* use the tplg configured mclk if existed */
-	if (!dai || !private || !private->dai_config)
+	if (!dai)
+		return 0;
+	private = dai->private;
+	if (!private || !private->dai_config)
 		return 0;
 
 	switch (private->dai_config->type) {
-- 
2.20.1


  reply	other threads:[~2022-03-18  7:14 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-18  7:12 [PATCH 1/2] ASoC: SOF: Prevent NULL dereference in sof_pcm_dai_link_fixup() Dan Carpenter
2022-03-18  7:12 ` Dan Carpenter
2022-03-18  7:13 ` Dan Carpenter [this message]
2022-03-18  7:13   ` [PATCH 2/2] ASoC: SOF: check for NULL before dereferencing Dan Carpenter
2022-03-18 14:51   ` Pierre-Louis Bossart
2022-03-18 14:51     ` Pierre-Louis Bossart
2022-03-18 14:42 ` [PATCH 1/2] ASoC: SOF: Prevent NULL dereference in sof_pcm_dai_link_fixup() Pierre-Louis Bossart
2022-03-18 14:42   ` Pierre-Louis Bossart
2022-03-18 16:14   ` Ranjani Sridharan
2022-03-18 16:14     ` Ranjani Sridharan
2022-03-18 17:49     ` Mark Brown
2022-03-18 17:49       ` Mark Brown
2022-03-20 14:33 ` [Sound-open-firmware] " Curtis Malainey

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=20220318071308.GC29472@kili \
    --to=dan.carpenter@oracle.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=daniel.baluta@nxp.com \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=lgirdwood@gmail.com \
    --cc=peter.ujfalusi@linux.intel.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=ranjani.sridharan@linux.intel.com \
    --cc=sound-open-firmware@alsa-project.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 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.