mtd: ssfdc: Adjustments for ssfdcr_add_mtd()
Subsystems (2)
cover mtd: ssfdc: Adjustments for ssfdcr_add_mtd()
From: Markus Elfring <[email protected]>
Date: Wed, 27 Dec 2023 15:38:42 +0100
A few update suggestions were taken into account
from static source code analysis.
Markus Elfring (3):
One function call less after error detection
Fix indentation
Improve a size determination
drivers/mtd/ssfdc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
--
2.43.0
PATCH 1/3 mtd: ssfdc: One function call less in ssfdcr_add_mtd() after error detection
From: Markus Elfring <[email protected]>
Date: Wed, 27 Dec 2023 13:21:52 +0100
The kfree() function was called in one case by
the ssfdcr_add_mtd() function during error handling even if the passed data structure member contained a null pointer. This issue was detected by using the Coccinelle software.
Thus use another label.
--- drivers/mtd/ssfdc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/mtd/ssfdc.c +2 -1
@@ -332,7 +332,7 @@ static void ssfdcr_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)kmalloc_array (ssfdc->map_len,sizeof (ssfdc->logic_block_map[0 ]),GFP_KERNEL );if (!ssfdc->logic_block_map) - goto out_err; + goto out_free_ssfdc;memset (ssfdc->logic_block_map,0xff ,sizeof (ssfdc->logic_block_map[0 ]) * ssfdc->map_len);
@@ -350,6 +350,7 @@ static void ssfdcr_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) out_err:kfree (ssfdc->logic_block_map); +out_free_ssfdc:kfree (ssfdc); }
--
2.43.0
PATCH 2/3 mtd: ssfdc: Fix indentation in ssfdcr_add_mtd()
In reply to Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 27 Dec 2023 15:17:58 +0100
Replace eight space characters by one tab.
--- drivers/mtd/ssfdc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/ssfdc.c +1 -1
@@ -351,7 +351,7 @@ static void ssfdcr_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) out_err:kfree (ssfdc->logic_block_map); out_free_ssfdc: -kfree (ssfdc); +kfree (ssfdc); }static void ssfdcr_remove_dev (struct mtd_blktrans_dev *dev)
--
2.43.0
PATCH 3/3 mtd: ssfdc: Improve a size determination in ssfdcr_add_mtd()
In reply to Markus ElfringFrom: Markus Elfring <[email protected]>
Date: Wed, 27 Dec 2023 15:30:06 +0100
Replace the specification of a data structure by a pointer dereference as the parameter for the operator "sizeof" to make the corresponding size determination a bit safer according to the Linux coding style convention.
--- drivers/mtd/ssfdc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/ssfdc.c +1 -1
@@ -295,7 +295,7 @@ static void ssfdcr_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd)if (cis_sector ==-1 )return ; - ssfdc =kzalloc (sizeof (struct ssfdcr_record ),GFP_KERNEL ); + ssfdc =kzalloc (sizeof (*ssfdc),GFP_KERNEL );if (!ssfdc)return ;
--
2.43.0
Miquel Raynal
maintainerHi Markus,
[email protected] wrote on Wed, 27 Dec 2023 15:43:06 +0100:
Quoted 11 lines
From: Markus Elfring <[email protected]>
Date: Wed, 27 Dec 2023 15:38:42 +0100A few update suggestions were taken into account
from static source code analysis.Markus Elfring (3):
One function call less after error detection
Fix indentation
Improve a size determination
Quoted 6 lines
drivers/mtd/ssfdc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)--
2.43.0
Series applied on top of mtd/next.
Thanks,
Miquèl