From: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
To: alsa-devel@alsa-project.org
Cc: tiwai@suse.de, broonie@kernel.org,
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Subject: [PATCH 4/8] ASoC: nau8821: clarify out-of-bounds check
Date: Mon, 25 Oct 2021 13:59:29 -0500 [thread overview]
Message-ID: <20211025185933.144327-5-pierre-louis.bossart@linux.intel.com> (raw)
In-Reply-To: <20211025185933.144327-1-pierre-louis.bossart@linux.intel.com>
cppcheck reports a false positive
sound/soc/codecs/nau8821.c:390:17: error: Array 'dmic_speed_sel[4]'
accessed at index 4, which is out of bounds. [arrayIndexOutOfBounds]
dmic_speed_sel[i].param, dmic_speed_sel[i].val);
^
sound/soc/codecs/nau8821.c:378:2: note: After for loop, i has value 4
for (i = 0 ; i < 4 ; i++)
^
sound/soc/codecs/nau8821.c:390:17: note: Array index out of bounds
dmic_speed_sel[i].param, dmic_speed_sel[i].val);
^
While the code is not incorrect, we can deal with the out-of-bounds
check in a clearer way that makes static analysis happy.
Signed-off-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
---
sound/soc/codecs/nau8821.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/codecs/nau8821.c b/sound/soc/codecs/nau8821.c
index 2757d2eeb48a..2de818377484 100644
--- a/sound/soc/codecs/nau8821.c
+++ b/sound/soc/codecs/nau8821.c
@@ -381,7 +381,7 @@ static int dmic_clock_control(struct snd_soc_dapm_widget *w,
speed_selection = dmic_speed_sel[i].val;
break;
}
- if (speed_selection < 0)
+ if (i == 4)
return -EINVAL;
dev_dbg(nau8821->dev,
--
2.25.1
next prev parent reply other threads:[~2021-10-25 19:02 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-25 18:59 [PATCH 0/8] ASoC: minor cleanup of warnings Pierre-Louis Bossart
2021-10-25 18:59 ` [PATCH 1/8] ASoC: topology: handle endianness warning Pierre-Louis Bossart
2021-10-25 18:59 ` [PATCH 2/8] ASoC: rt5682s: use 'static' qualifier Pierre-Louis Bossart
2021-10-25 18:59 ` [PATCH 3/8] ASoC: nau8821: fix kernel-doc Pierre-Louis Bossart
2021-10-25 18:59 ` Pierre-Louis Bossart [this message]
2021-10-25 18:59 ` [PATCH 5/8] ASoC: mediatek: remove unnecessary initialization Pierre-Louis Bossart
2021-10-25 18:59 ` [PATCH 6/8] ASoC: mediatek: mt8195: rename shadowed array Pierre-Louis Bossart
2021-10-25 18:59 ` [PATCH 7/8] ASoC: mediatek: mt8195: fix return value Pierre-Louis Bossart
2021-10-25 18:59 ` [PATCH 8/8] ASoC: rockchip: i2s_tdm: improve return value handling Pierre-Louis Bossart
2021-10-27 17:29 ` [PATCH 0/8] ASoC: minor cleanup of warnings 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=20211025185933.144327-5-pierre-louis.bossart@linux.intel.com \
--to=pierre-louis.bossart@linux.intel.com \
--cc=alsa-devel@alsa-project.org \
--cc=broonie@kernel.org \
--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.