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>,
"Péter Ujfalusi" <peter.ujfalusi@linux.intel.com>,
kernel-janitors@vger.kernel.org, "Takashi Iwai" <tiwai@suse.com>,
"Liam Girdwood" <lgirdwood@gmail.com>,
"Mark Brown" <broonie@kernel.org>,
"Bard Liao" <yung-chuan.liao@linux.intel.com>,
"Daniel Baluta" <daniel.baluta@nxp.com>,
sound-open-firmware@alsa-project.org
Subject: [PATCH 1/2] ASoC: SOF: Prevent NULL dereference in sof_pcm_dai_link_fixup()
Date: Fri, 18 Mar 2022 10:12:33 +0300 [thread overview]
Message-ID: <20220318071233.GB29472@kili> (raw)
The "dia" pointer can be NULL, so handle that condition first before
storing "dia->private".
Fixes: 839e484f9e17 ("ASoC: SOF: make struct snd_sof_dai IPC agnostic")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
sound/soc/sof/pcm.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c
index 1661b0bc6f12..71f5bce0c4c7 100644
--- a/sound/soc/sof/pcm.c
+++ b/sound/soc/sof/pcm.c
@@ -702,7 +702,7 @@ int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_pa
struct snd_sof_dai *dai =
snd_sof_find_dai(component, (char *)rtd->dai_link->name);
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
- struct sof_dai_private_data *private = dai->private;
+ struct sof_dai_private_data *private;
struct snd_soc_dpcm *dpcm;
/* no topology exists for this BE, try a common configuration */
@@ -727,6 +727,7 @@ int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_pa
/* read format from topology */
snd_mask_none(fmt);
+ private = dai->private;
switch (private->comp_dai->config.frame_fmt) {
case SOF_IPC_FRAME_S16_LE:
snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S16_LE);
--
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>,
"Péter Ujfalusi" <peter.ujfalusi@linux.intel.com>,
"Bard Liao" <yung-chuan.liao@linux.intel.com>,
sound-open-firmware@alsa-project.org,
alsa-devel@alsa-project.org, kernel-janitors@vger.kernel.org
Subject: [PATCH 1/2] ASoC: SOF: Prevent NULL dereference in sof_pcm_dai_link_fixup()
Date: Fri, 18 Mar 2022 10:12:33 +0300 [thread overview]
Message-ID: <20220318071233.GB29472@kili> (raw)
The "dia" pointer can be NULL, so handle that condition first before
storing "dia->private".
Fixes: 839e484f9e17 ("ASoC: SOF: make struct snd_sof_dai IPC agnostic")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
sound/soc/sof/pcm.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/sound/soc/sof/pcm.c b/sound/soc/sof/pcm.c
index 1661b0bc6f12..71f5bce0c4c7 100644
--- a/sound/soc/sof/pcm.c
+++ b/sound/soc/sof/pcm.c
@@ -702,7 +702,7 @@ int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_pa
struct snd_sof_dai *dai =
snd_sof_find_dai(component, (char *)rtd->dai_link->name);
struct snd_sof_dev *sdev = snd_soc_component_get_drvdata(component);
- struct sof_dai_private_data *private = dai->private;
+ struct sof_dai_private_data *private;
struct snd_soc_dpcm *dpcm;
/* no topology exists for this BE, try a common configuration */
@@ -727,6 +727,7 @@ int sof_pcm_dai_link_fixup(struct snd_soc_pcm_runtime *rtd, struct snd_pcm_hw_pa
/* read format from topology */
snd_mask_none(fmt);
+ private = dai->private;
switch (private->comp_dai->config.frame_fmt) {
case SOF_IPC_FRAME_S16_LE:
snd_mask_set_format(fmt, SNDRV_PCM_FORMAT_S16_LE);
--
2.20.1
next reply other threads:[~2022-03-18 7:13 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-18 7:12 Dan Carpenter [this message]
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:13 ` [PATCH 2/2] ASoC: SOF: check for NULL before dereferencing Dan Carpenter
2022-03-18 7:13 ` 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=20220318071233.GB29472@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.