* [PATCH] mtd: return -ENOMEM when kmalloc failed
@ 2021-04-26 9:32 ` Yang Li
0 siblings, 0 replies; 4+ messages in thread
From: Yang Li @ 2021-04-26 9:32 UTC (permalink / raw)
To: miquel.raynal; +Cc: richard, vigneshr, linux-mtd, linux-kernel, Yang Li
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>
---
drivers/mtd/inftlmount.c | 2 +-
drivers/mtd/nftlmount.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/inftlmount.c b/drivers/mtd/inftlmount.c
index af16d34..39d0241 100644
--- a/drivers/mtd/inftlmount.c
+++ b/drivers/mtd/inftlmount.c
@@ -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) {
diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
index 444a77b..fd331bc 100644
--- a/drivers/mtd/nftlmount.c
+++ b/drivers/mtd/nftlmount.c
@@ -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) {
--
1.8.3.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] mtd: return -ENOMEM when kmalloc failed
@ 2021-04-26 9:32 ` Yang Li
0 siblings, 0 replies; 4+ messages in thread
From: Yang Li @ 2021-04-26 9:32 UTC (permalink / raw)
To: miquel.raynal; +Cc: richard, vigneshr, linux-mtd, linux-kernel, Yang Li
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>
---
drivers/mtd/inftlmount.c | 2 +-
drivers/mtd/nftlmount.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/inftlmount.c b/drivers/mtd/inftlmount.c
index af16d34..39d0241 100644
--- a/drivers/mtd/inftlmount.c
+++ b/drivers/mtd/inftlmount.c
@@ -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) {
diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c
index 444a77b..fd331bc 100644
--- a/drivers/mtd/nftlmount.c
+++ b/drivers/mtd/nftlmount.c
@@ -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) {
--
1.8.3.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] mtd: return -ENOMEM when kmalloc failed
2021-04-26 9:32 ` Yang Li
@ 2021-05-10 10:43 ` Miquel Raynal
-1 siblings, 0 replies; 4+ messages in thread
From: Miquel Raynal @ 2021-05-10 10:43 UTC (permalink / raw)
To: Yang Li, miquel.raynal; +Cc: richard, vigneshr, linux-mtd, linux-kernel
On Mon, 2021-04-26 at 09:32:23 UTC, Yang Li wrote:
> 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>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.
Miquel
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] mtd: return -ENOMEM when kmalloc failed
@ 2021-05-10 10:43 ` Miquel Raynal
0 siblings, 0 replies; 4+ messages in thread
From: Miquel Raynal @ 2021-05-10 10:43 UTC (permalink / raw)
To: Yang Li, miquel.raynal; +Cc: richard, vigneshr, linux-mtd, linux-kernel
On Mon, 2021-04-26 at 09:32:23 UTC, Yang Li wrote:
> 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>
Applied to https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git mtd/next, thanks.
Miquel
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-05-10 11:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-26 9:32 [PATCH] mtd: return -ENOMEM when kmalloc failed Yang Li
2021-04-26 9:32 ` Yang Li
2021-05-10 10:43 ` Miquel Raynal
2021-05-10 10:43 ` Miquel Raynal
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.