public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Adrian Hunter <adrian.hunter@nokia.com>
To: Roel Kluin <roel.kluin@gmail.com>
Cc: "kyungmin.park@samsung.com" <kyungmin.park@samsung.com>,
	"linux-mtd@lists.infradead.org" <linux-mtd@lists.infradead.org>,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] onenand: test before subtraction on unsigned
Date: Wed, 04 Mar 2009 16:49:48 +0200	[thread overview]
Message-ID: <49AE950C.60907@nokia.com> (raw)
In-Reply-To: <49AE8BA0.7060903@gmail.com>

Roel Kluin wrote:
> 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;

len is not used anymore, so no need to set it to zero.

>  				ret = -ENOSPC;
>  				break;
>  			}
> +			len -= sizeof(struct otp_info);
>  
>  			otpinfo = (struct otp_info *) buf;
>  			otpinfo->start = from;

So is there somewhere that is passing a buffer too small for all the opt_info?

  reply	other threads:[~2009-03-04 14:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-04 14:09 [PATCH] onenand: test before subtraction on unsigned Roel Kluin
2009-03-04 14:49 ` Adrian Hunter [this message]
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=49AE950C.60907@nokia.com \
    --to=adrian.hunter@nokia.com \
    --cc=akpm@linux-foundation.org \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-mtd@lists.infradead.org \
    --cc=roel.kluin@gmail.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