]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
mtd: nand: use ssize_t instead of size_t to prevent infinite loop
authorhtbegin <hotforest@gmail.com>
Fri, 1 Mar 2013 23:00:34 +0000 (23:00 +0000)
committerScott Wood <scottwood@freescale.com>
Wed, 22 May 2013 21:50:59 +0000 (16:50 -0500)
When a all 0xFF buffer is passed to drop_ffs, the no-0xFF check loop
will loop forever.
After the fix, If ssize_t i = -1 and size_t l = i + 1, the value of l
will still be 0 as expected.

Signed-off-by: Tao Hou <hotforest@gmail.com>
Cc: Ben Gardiner <bengardiner@nanometrics.ca>
Cc: Scott Wood <scottwood@freescale.com>
drivers/mtd/nand/nand_util.c

index 4727f9c9892517df97b5951e88f11b384177ba01..fe8bdeb0ea32c4f4c0c9cd51fb5e54e1073c1ba1 100644 (file)
@@ -458,7 +458,8 @@ static int check_skip_len(nand_info_t *nand, loff_t offset, size_t length,
 static size_t drop_ffs(const nand_info_t *nand, const u_char *buf,
                        const size_t *len)
 {
-       size_t i, l = *len;
+       size_t l = *len;
+       ssize_t i;
 
        for (i = l - 1; i >= 0; i--)
                if (buf[i] != 0xFF)