From: Nicolin Chen <nicoleotsuka@gmail.com>
To: <broonie@kernel.org>
Cc: <linux-kernel@vger.kernel.org>, <linuxppc-dev@lists.ozlabs.org>,
<alsa-devel@alsa-project.org>, <timur@tabi.org>
Subject: [PATCH 1/2] ASoC: fsl_sarc_dma: Check pair before using it
Date: Mon, 4 Aug 2014 12:19:48 +0800 [thread overview]
Message-ID: <5a5ffb6219ec5ade81511be9dfbdbeef311f1a16.1407125653.git.nicoleotsuka@gmail.com> (raw)
In-Reply-To: <cover.1407125653.git.nicoleotsuka@gmail.com>
The patch 3117bb3109dc: "ASoC: fsl_asrc: Add ASRC ASoC CPU DAI and
platform drivers" from Jul 29, 2014, leads to the following Smatch
complaint:
sound/soc/fsl/fsl_asrc_dma.c:304 fsl_asrc_dma_shutdown()
warn: variable dereferenced before check 'pair' (see line 302)
sound/soc/fsl/fsl_asrc_dma.c
301 struct fsl_asrc_pair *pair = runtime->private_data;
302 struct fsl_asrc *asrc_priv = pair->asrc_priv;
^^^^^^^^^^^^^^^
Dereference.
303
304 if (pair && asrc_priv->pair[pair->index] == pair)
^^^^
Check.
305 asrc_priv->pair[pair->index] = NULL;
306
So we just let the driver check pair before using it.
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Nicolin Chen <nicoleotsuka@gmail.com>
---
sound/soc/fsl/fsl_asrc_dma.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/sound/soc/fsl/fsl_asrc_dma.c b/sound/soc/fsl/fsl_asrc_dma.c
index 5b1e73e..ffc000b 100644
--- a/sound/soc/fsl/fsl_asrc_dma.c
+++ b/sound/soc/fsl/fsl_asrc_dma.c
@@ -299,9 +299,14 @@ static int fsl_asrc_dma_shutdown(struct snd_pcm_substream *substream)
{
struct snd_pcm_runtime *runtime = substream->runtime;
struct fsl_asrc_pair *pair = runtime->private_data;
- struct fsl_asrc *asrc_priv = pair->asrc_priv;
+ struct fsl_asrc *asrc_priv;
+
+ if (!pair)
+ return 0;
+
+ asrc_priv = pair->asrc_priv;
- if (pair && asrc_priv->pair[pair->index] == pair)
+ if (asrc_priv->pair[pair->index] == pair)
asrc_priv->pair[pair->index] = NULL;
kfree(pair);
--
1.8.4
next prev parent reply other threads:[~2014-08-04 4:17 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-04 4:19 [PATCH 0/2] ASoC: fsl_asrc: Fix two dereferenced variable before check Nicolin Chen
2014-08-04 4:19 ` Nicolin Chen [this message]
2014-08-04 4:19 ` [PATCH 2/2] ASoC: fsl_asrc: Don't access members of config before checking it Nicolin Chen
2014-08-04 14:48 ` [PATCH 0/2] ASoC: fsl_asrc: Fix two dereferenced variable before check 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=5a5ffb6219ec5ade81511be9dfbdbeef311f1a16.1407125653.git.nicoleotsuka@gmail.com \
--to=nicoleotsuka@gmail.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=timur@tabi.org \
/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
all inboxes | Powered by JetHome®