Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: nftl: reorganize operations in condition check

We need to compare ret variable for negative value. The current code
assigns the boolean to the ret and prints it wrongly in the warning
message.

Reported-by: Andrey Karpov <karpov@viva64.com>
Cc: Giel van Schijndel <me@mortis.eu>
Cc: Dimitri Gorokhovik <dimitri.gorokhovik@free.fr>
Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>

authored by

Andy Shevchenko and committed by
Brian Norris
768c57c8 57f5ef14

+11 -7
+11 -7
drivers/mtd/nftlmount.c
··· 89 89 } 90 90 91 91 /* To be safer with BIOS, also use erase mark as discriminant */ 92 - if ((ret = nftl_read_oob(mtd, block * nftl->EraseSize + 92 + ret = nftl_read_oob(mtd, block * nftl->EraseSize + 93 93 SECTORSIZE + 8, 8, &retlen, 94 - (char *)&h1) < 0)) { 94 + (char *)&h1); 95 + if (ret < 0) { 95 96 printk(KERN_WARNING "ANAND header found at 0x%x in mtd%d, but OOB data read failed (err %d)\n", 96 97 block * nftl->EraseSize, nftl->mbd.mtd->index, ret); 97 98 continue; ··· 110 109 } 111 110 112 111 /* Finally reread to check ECC */ 113 - if ((ret = mtd->read(mtd, block * nftl->EraseSize, SECTORSIZE, 114 - &retlen, buf) < 0)) { 112 + ret = mtd->read(mtd, block * nftl->EraseSize, SECTORSIZE, 113 + &retlen, buf); 114 + if (ret < 0) { 115 115 printk(KERN_NOTICE "ANAND header found at 0x%x in mtd%d, but ECC read failed (err %d)\n", 116 116 block * nftl->EraseSize, nftl->mbd.mtd->index, ret); 117 117 continue; ··· 230 228 The new DiskOnChip driver already scanned the bad block table. Just query it. 231 229 if ((i & (SECTORSIZE - 1)) == 0) { 232 230 /* read one sector for every SECTORSIZE of blocks */ 233 - if ((ret = mtd->read(nftl->mbd.mtd, block * nftl->EraseSize + 234 - i + SECTORSIZE, SECTORSIZE, &retlen, 235 - buf)) < 0) { 231 + ret = mtd->read(nftl->mbd.mtd, 232 + block * nftl->EraseSize + i + 233 + SECTORSIZE, SECTORSIZE, 234 + &retlen, buf); 235 + if (ret < 0) { 236 236 printk(KERN_NOTICE "Read of bad sector table failed (err %d)\n", 237 237 ret); 238 238 kfree(nftl->ReplUnitTable);