From: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
To: oder_chiou@realtek.com, Liam Girdwood <lgirdwood@gmail.com>,
broonie@kernel.org, perex@perex.cz, tiwai@suse.com,
shumingf@realtek.com
Cc: linux-sound@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
smatch@vger.kernel.org, Dan Carpenter <error27@gmail.com>
Subject: ASoC: rt* codecs: fix regmap_config.max_register off-by-one
Date: Mon, 23 Mar 2026 14:37:39 +0530 [thread overview]
Message-ID: <291bffe8-bb0e-44bb-9ecf-aa69aa93bc86@oracle.com> (raw)
Hi all,
I wanted to first share a summary of possible off-by-one bugs and
confirm these are real fixes worth posting.
I wrote a smatch check to complain if max_register is a power of 2, and
have reviewed the warnings. I think the below warnings are true positives.
regmap_config.max_register is inclusive (it is the highest valid
register address), not a register count.
The drivers below currently use + 1, which allows one invalid extra
register address.
sound/soc/codecs/rt1305.c
static const struct regmap_config rt1305_regmap = {
.reg_bits = 8,
.val_bits = 16,
.max_register = RT1305_MAX_REG + 1 + (ARRAY_SIZE(rt1305_ranges) *
RT1305_PR_SPACING),
Values: 0xff + 1 + (1 * 0x100) = 0x200
I think the correct value is 0xff + (1 * 0x100) = 0x1ff
There are similar issues in other
- sound/soc/codecs/rt1305.c
- sound/soc/codecs/rt5616.c
- sound/soc/codecs/rt5640.c
- sound/soc/codecs/rt5645.c
- sound/soc/codecs/rt5651.c
- sound/soc/codecs/rt5660.c
- sound/soc/codecs/rt5670.c
- sound/soc/codecs/rt5677.c
So I thought of checking here if these need fixing before making patches.
Note: these are purely based on static analysis and can't really test these.
Thanks,
Harshit
reply other threads:[~2026-03-23 9:08 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=291bffe8-bb0e-44bb-9ecf-aa69aa93bc86@oracle.com \
--to=harshit.m.mogalapalli@oracle.com \
--cc=broonie@kernel.org \
--cc=error27@gmail.com \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sound@vger.kernel.org \
--cc=oder_chiou@realtek.com \
--cc=perex@perex.cz \
--cc=shumingf@realtek.com \
--cc=smatch@vger.kernel.org \
--cc=tiwai@suse.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox