]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
mtd: *nftl: return -ENOMEM when kmalloc failed
authorYang Li <yang.lee@linux.alibaba.com>
Mon, 26 Apr 2021 09:32:23 +0000 (17:32 +0800)
committerMiquel Raynal <miquel.raynal@bootlin.com>
Mon, 10 May 2021 10:47:40 +0000 (12:47 +0200)
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
drivers/mtd/inftlmount.c
drivers/mtd/nftlmount.c

index af16d3485de045c32d02be2bc4aa5bbaeff17307..39d0241186102641eb89769386d4e38da6ec515a 100644 (file)
@@ -330,7 +330,7 @@ static int check_free_sectors(struct INFTLrecord *inftl, unsigned int address,
 
        buf = kmalloc(SECTORSIZE + mtd->oobsize, GFP_KERNEL);
        if (!buf)
-               return -1;
+               return -ENOMEM;
 
        ret = -1;
        for (i = 0; i < len; i += SECTORSIZE) {
index 444a77bb7692134ada6fd673502f9ea03c1891bb..fd331bc15871f694bb51ddd1206e4f651af11b57 100644 (file)
@@ -269,7 +269,7 @@ static int check_free_sectors(struct NFTLrecord *nftl, unsigned int address, int
 
        buf = kmalloc(SECTORSIZE + mtd->oobsize, GFP_KERNEL);
        if (!buf)
-               return -1;
+               return -ENOMEM;
 
        ret = -1;
        for (i = 0; i < len; i += SECTORSIZE) {