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

mtd: *nftl: return -ENOMEM when kmalloc failed

The driver is using -1 instead of the -ENOMEM defined macro to
specify that a buffer allocation failed. Using the correct error
code is more intuitive

Smatch tool warning:
drivers/mtd/inftlmount.c:333 check_free_sectors() warn: returning -1
instead of -ENOMEM is sloppy
drivers/mtd/nftlmount.c:272 check_free_sectors() warn: returning -1
instead of -ENOMEM is sloppy

No functional change, just more standardized.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
[<miquel.raynal@bootlin.com>: Fixed the title]
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/1619429543-52234-1-git-send-email-yang.lee@linux.alibaba.com

authored by

Yang Li and committed by
Miquel Raynal
9c5b19c2 6500dc2b

+2 -2
+1 -1
drivers/mtd/inftlmount.c
··· 330 330 331 331 buf = kmalloc(SECTORSIZE + mtd->oobsize, GFP_KERNEL); 332 332 if (!buf) 333 - return -1; 333 + return -ENOMEM; 334 334 335 335 ret = -1; 336 336 for (i = 0; i < len; i += SECTORSIZE) {
+1 -1
drivers/mtd/nftlmount.c
··· 269 269 270 270 buf = kmalloc(SECTORSIZE + mtd->oobsize, GFP_KERNEL); 271 271 if (!buf) 272 - return -1; 272 + return -ENOMEM; 273 273 274 274 ret = -1; 275 275 for (i = 0; i < len; i += SECTORSIZE) {