From: Taylor Hutt <thutt@chromium.org>
To: Peter Hsiang <peter.hsiang@maxim-ic.com>
Cc: Liam Girdwood <lrg@slimlogic.co.uk>,
Mark Brown <broonie@opensource.wolfsonmicro.com>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.de>,
Taylor Hutt <thutt@chromium.org>,
alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org
Subject: [PATCH] Max98095: Move existing NULL check before pointer dereference.
Date: Tue, 17 May 2011 18:03:54 -0700 [thread overview]
Message-ID: <1305680634-10484-1-git-send-email-thutt@chromium.org> (raw)
Visual inspection shows that max98095_put_eq_enum() and
max98095_put_bq_enum() each have a possible NULL deref of 'pdata'.
This change moves the NULL check above the use.
BUG=none
TEST=Visual inspection
Change-Id: Ic53a7e38a958f39225ac4961bcfd3812a95ea1b5
Signed-off-by: Taylor Hutt <thutt@chromium.org>
---
sound/soc/codecs/max98095.c | 16 ++++++----------
1 files changed, 6 insertions(+), 10 deletions(-)
diff --git a/sound/soc/codecs/max98095.c b/sound/soc/codecs/max98095.c
index a6cc94e..e1d282d 100644
--- a/sound/soc/codecs/max98095.c
+++ b/sound/soc/codecs/max98095.c
@@ -1872,16 +1872,14 @@ static int max98095_put_eq_enum(struct snd_kcontrol *kcontrol,
BUG_ON(channel > 1);
- cdata = &max98095->dai[channel];
+ if (!pdata || !max98095->eq_textcnt)
+ return 0;
if (sel >= pdata->eq_cfgcnt)
return -EINVAL;
+ cdata = &max98095->dai[channel];
cdata->eq_sel = sel;
-
- if (!pdata || !max98095->eq_textcnt)
- return 0;
-
fs = cdata->rate;
/* Find the selected configuration with nearest sample rate */
@@ -2020,16 +2018,14 @@ static int max98095_put_bq_enum(struct snd_kcontrol *kcontrol,
BUG_ON(channel > 1);
- cdata = &max98095->dai[channel];
+ if (!pdata || !max98095->bq_textcnt)
+ return 0;
if (sel >= pdata->bq_cfgcnt)
return -EINVAL;
+ cdata = &max98095->dai[channel];
cdata->bq_sel = sel;
-
- if (!pdata || !max98095->bq_textcnt)
- return 0;
-
fs = cdata->rate;
/* Find the selected configuration with nearest sample rate */
--
1.7.3.1
next reply other threads:[~2011-05-18 1:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-18 1:03 Taylor Hutt [this message]
2011-05-18 1:28 ` [PATCH] Max98095: Move existing NULL check before pointer dereference Peter Hsiang
2011-05-18 7:06 ` Mark Brown
2011-05-18 13:53 ` Peter Hsiang
2011-05-18 9:32 ` Liam Girdwood
2011-05-18 16:38 ` 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=1305680634-10484-1-git-send-email-thutt@chromium.org \
--to=thutt@chromium.org \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lrg@slimlogic.co.uk \
--cc=perex@perex.cz \
--cc=peter.hsiang@maxim-ic.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).