public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] OneNAND: Fix test of unsigned in onenand_otp_walk()
@ 2009-12-16  0:37 Roel Kluin
  2009-12-16  1:20 ` Kyungmin Park
  0 siblings, 1 reply; 2+ messages in thread
From: Roel Kluin @ 2009-12-16  0:37 UTC (permalink / raw)
  To: Kyungmin Park, linux-mtd, Andrew Morton, LKML

mtd->writesize and len are unsigned so the test does not work.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
you can test this with:

#include <stdio.h>

int main()
{
        int c = 1, d = 1;
        unsigned a = 30;
        unsigned b = 10;

        if ((b * c) - (d + a) < 0)
                printf("good\n");
        else
                printf("bad\n");
        return 0;
}


diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c
index ff66e43..cbe2711 100644
--- a/drivers/mtd/onenand/onenand_base.c
+++ b/drivers/mtd/onenand/onenand_base.c
@@ -2725,7 +2725,7 @@ static int onenand_otp_walk(struct mtd_info *mtd, loff_t from, size_t len,
 	}
 
 	/* Check User/Factory boundary */
-	if (((mtd->writesize * otp_pages) - (from + len)) < 0)
+	if (mtd->writesize * otp_pages < from + len)
 		return 0;
 
 	onenand_get_device(mtd, FL_OTPING);

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-12-16  1:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-16  0:37 [PATCH] OneNAND: Fix test of unsigned in onenand_otp_walk() Roel Kluin
2009-12-16  1:20 ` Kyungmin Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox