From: Phil Carmody <ext-phil.2.carmody@nokia.com>
To: broonie@opensource.wolfsonmicro.com, sameo@linux.intel.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] mfd: Fix fencepost error in reg cache access check
Date: Fri, 16 Apr 2010 15:00:09 +0300 [thread overview]
Message-ID: <1271419209-21634-1-git-send-email-ext-phil.2.carmody@nokia.com> (raw)
From: Phil Carmody <ext-phil.2.carmody@nokia.com>
Accessing num_reg elements in the interval [reg .. reg+num_regs)
is permitted if (reg+numregs <= array size), so barf when that
excluded upper bound is > array size. The prior -1 would give
access to one too many elements.
Signed-off-by: Phil Carmody <ext-phil.2.carmody@nokia.com>
---
drivers/mfd/wm8400-core.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/mfd/wm8400-core.c b/drivers/mfd/wm8400-core.c
index 865ce01..e08aafa 100644
--- a/drivers/mfd/wm8400-core.c
+++ b/drivers/mfd/wm8400-core.c
@@ -118,7 +118,7 @@ static int wm8400_read(struct wm8400 *wm8400, u8 reg, int num_regs, u16 *dest)
{
int i, ret = 0;
- BUG_ON(reg + num_regs - 1 > ARRAY_SIZE(wm8400->reg_cache));
+ BUG_ON(reg + num_regs > ARRAY_SIZE(wm8400->reg_cache));
/* If there are any volatile reads then read back the entire block */
for (i = reg; i < reg + num_regs; i++)
@@ -144,7 +144,7 @@ static int wm8400_write(struct wm8400 *wm8400, u8 reg, int num_regs,
{
int ret, i;
- BUG_ON(reg + num_regs - 1 > ARRAY_SIZE(wm8400->reg_cache));
+ BUG_ON(reg + num_regs > ARRAY_SIZE(wm8400->reg_cache));
for (i = 0; i < num_regs; i++) {
BUG_ON(!reg_data[reg + i].writable);
--
1.6.0.4
next reply other threads:[~2010-04-16 11:57 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-16 12:00 Phil Carmody [this message]
2010-04-16 18:50 ` [PATCH] mfd: Fix fencepost error in reg cache access 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=1271419209-21634-1-git-send-email-ext-phil.2.carmody@nokia.com \
--to=ext-phil.2.carmody@nokia.com \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sameo@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 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).