From: Roel Kluin <roel.kluin@gmail.com>
To: kyungmin.park@samsung.com
Cc: Andrew Morton <akpm@linux-foundation.org>, linux-mtd@lists.infradead.org
Subject: [PATCH] onenand: test before subtraction on unsigned
Date: Wed, 04 Mar 2009 15:09:36 +0100 [thread overview]
Message-ID: <49AE8BA0.7060903@gmail.com> (raw)
len is unsigned so will wrap around when sizeof(struct otp_info) is greater than
len.
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index 529af27..7c2ebe9 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -2296,11 +2296,12 @@ static int onenand_otp_walk(struct mtd_info *mtd, loff_t from, size_t len,
if (!action) { /* OTP Info functions */
struct otp_info *otpinfo;
- len -= sizeof(struct otp_info);
- if (len <= 0) {
+ if (len <= sizeof(struct otp_info)) {
+ len = 0;
ret = -ENOSPC;
break;
}
+ len -= sizeof(struct otp_info);
otpinfo = (struct otp_info *) buf;
otpinfo->start = from;
next reply other threads:[~2009-03-04 14:09 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-04 14:09 Roel Kluin [this message]
2009-03-04 14:49 ` [PATCH] onenand: test before subtraction on unsigned Adrian Hunter
2009-03-04 15:18 ` Roel Kluin
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=49AE8BA0.7060903@gmail.com \
--to=roel.kluin@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=kyungmin.park@samsung.com \
--cc=linux-mtd@lists.infradead.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