]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
mtd: sharpslpart: Fix unsigned comparison to zero
authorYueHaibing <yuehaibing@huawei.com>
Mon, 30 Dec 2019 03:29:45 +0000 (11:29 +0800)
committerKhalid Elmously <khalid.elmously@canonical.com>
Fri, 13 Mar 2020 04:31:00 +0000 (00:31 -0400)
BugLink: https://bugs.launchpad.net/bugs/1867194
commit f33113b542219448fa02d77ca1c6f4265bd7f130 upstream.

The unsigned variable log_num is being assigned a return value
from the call to sharpsl_nand_get_logical_num that can return
-EINVAL.

Detected using Coccinelle:
./drivers/mtd/parsers/sharpslpart.c:207:6-13: WARNING: Unsigned expression compared with zero: log_num > 0

Fixes: 8a4580e4d298 ("mtd: sharpslpart: Add sharpslpart partition parser")
Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
drivers/mtd/parsers/sharpslpart.c

index 5fe0079ea5ede7acb1168bc33c76cebbd78e69c6..95273cb5c3f1f66ec34f3ef94671707d4f9f5829 100644 (file)
@@ -165,10 +165,10 @@ static int sharpsl_nand_get_logical_num(u8 *oob)
 
 static int sharpsl_nand_init_ftl(struct mtd_info *mtd, struct sharpsl_ftl *ftl)
 {
-       unsigned int block_num, log_num, phymax;
+       unsigned int block_num, phymax;
+       int i, ret, log_num;
        loff_t block_adr;
        u8 *oob;
-       int i, ret;
 
        oob = kzalloc(mtd->oobsize, GFP_KERNEL);
        if (!oob)