Skip to contentSkip to conversation

mtd: rawnand: fix memdup.cocci warnings

PATCH New Julia Lawall 1 participant 1 message Mar 2, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: rawnand: fix memdup.cocci warnings

From: Fengguang Wu <[email protected]>

Use kmemdup rather than duplicating its implementation

Generated by: scripts/coccinelle/api/memdup.cocci

Signed-off-buy: Julia Lawall <[email protected]>
---

tree:   https://github.com/bbrezillon/linux-0day mraynal/nand-scan
head:   0fdb0ec57e123aae03d1c52f8ba5fb6c8c8f98ed
commit: d4d20cd03273ee0d1bb874dc33170286216b6320 [70/71] mtd: rawnand: do

not export nand_scan_[ident|tail]() anymore

 nand_base.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/mtd/nand/raw/nand_base.c +1 -2
@@ -5160,13 +5160,12 @@ static int nand_flash_detect_onfi(struct
 
 	sanitize_string(p->manufacturer, sizeof(p->manufacturer));
 	sanitize_string(p->model, sizeof(p->model));
-	model = kzalloc(sizeof(p->model), GFP_KERNEL);
+	model = kmemdup(p->model, sizeof(p->model), GFP_KERNEL);
 	if (!model) {
 		ret = -ENOMEM;
 		goto free_onfi_param_page;
 	}
 
-	memcpy(model, p->model, sizeof(p->model));
 	chip->parameters.model = model;
 	if (!mtd->name)
 		mtd->name = chip->parameters.model;