Commit 9c5b19c2 authored by Yang Li's avatar Yang Li Committed by Miquel Raynal
Browse files

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: default avatarAbaci Robot <abaci@linux.alibaba.com>
Signed-off-by: default avatarYang Li <yang.lee@linux.alibaba.com>
[<miquel.raynal@bootlin.com>: Fixed the title]
Signed-off-by: default avatarMiquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/1619429543-52234-1-git-send-email-yang.lee@linux.alibaba.com
parent 6500dc2b
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -330,7 +330,7 @@ static int check_free_sectors(struct INFTLrecord *inftl, unsigned int address,


	buf = kmalloc(SECTORSIZE + mtd->oobsize, GFP_KERNEL);
	buf = kmalloc(SECTORSIZE + mtd->oobsize, GFP_KERNEL);
	if (!buf)
	if (!buf)
		return -1;
		return -ENOMEM;


	ret = -1;
	ret = -1;
	for (i = 0; i < len; i += SECTORSIZE) {
	for (i = 0; i < len; i += SECTORSIZE) {
+1 −1
Original line number Original line Diff line number Diff line
@@ -269,7 +269,7 @@ static int check_free_sectors(struct NFTLrecord *nftl, unsigned int address, int


	buf = kmalloc(SECTORSIZE + mtd->oobsize, GFP_KERNEL);
	buf = kmalloc(SECTORSIZE + mtd->oobsize, GFP_KERNEL);
	if (!buf)
	if (!buf)
		return -1;
		return -ENOMEM;


	ret = -1;
	ret = -1;
	for (i = 0; i < len; i += SECTORSIZE) {
	for (i = 0; i < len; i += SECTORSIZE) {