Skip to content

Commit

Permalink
mtd: *nftl: return -ENOMEM when kmalloc failed
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Yang Li authored and Miquel Raynal committed May 10, 2021
1 parent 6500dc2 commit 9c5b19c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion drivers/mtd/inftlmount.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/mtd/nftlmount.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 9c5b19c

Please sign in to comment.