Skip to contentSkip to conversation

mptfusion: Use kmemdup rather than duplicating its implementation

PATCH In review Thomas Meyer 2 participants 2 messages Nov 19, 2011 – Dec 19, 2011

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

PATCH 1/1 mptfusion: Use kmemdup rather than duplicating its implementation

The semantic patch that makes this change is available in scripts/coccinelle/api/memdup.cocci.

---

drivers/message/fusion/mptbase.c 2011-11-08 10:40:23.121014643 +0100 renamed from drivers/message/fusion/mptbase.c 2011-11-07 19:37:51.796676955 +0100 +1 -2
diff -u -p a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
@@ -6003,13 +6003,12 @@ mpt_findImVolumes(MPT_ADAPTER *ioc)
 	if (mpt_config(ioc, &cfg) != 0)
 		goto out;
 
-	mem = kmalloc(iocpage2sz, GFP_KERNEL);
+	mem = kmemdup((u8 *)pIoc2, iocpage2sz, GFP_KERNEL);
 	if (!mem) {
 		rc = -ENOMEM;
 		goto out;
 	}
 
-	memcpy(mem, (u8 *)pIoc2, iocpage2sz);
 	ioc->raid_data.pIocPg2 = (IOCPage2_t *) mem;
 
 	mpt_read_ioc_pg_3(ioc);
#1 lore raw

This patch seem to be fine.
Please consider this patch as acked by me.

Regards,
Nagalakshmi

-----Original Message-----
From: Thomas Meyer [mailto:[email protected]]
Sent: Friday, November 18, 2011 4:14 AM
To: DL-MPT Fusion Linux; [email protected]; [email protected]
Subject: [PATCH] [SCSI] mptfusion: Use kmemdup rather than duplicating its implementation

The semantic patch that makes this change is available in scripts/coccinelle/api/memdup.cocci.

---

drivers/message/fusion/mptbase.c 2011-11-08 10:40:23.121014643 +0100 renamed from drivers/message/fusion/mptbase.c 2011-11-07 19:37:51.796676955 +0100 +1 -2
diff -u -p a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
@@ -6003,13 +6003,12 @@ mpt_findImVolumes(MPT_ADAPTER *ioc)
 	if (mpt_config(ioc, &cfg) != 0)
 		goto out;
 
-	mem = kmalloc(iocpage2sz, GFP_KERNEL);
+	mem = kmemdup((u8 *)pIoc2, iocpage2sz, GFP_KERNEL);
 	if (!mem) {
 		rc = -ENOMEM;
 		goto out;
 	}
 
-	memcpy(mem, (u8 *)pIoc2, iocpage2sz);
 	ioc->raid_data.pIocPg2 = (IOCPage2_t *) mem;
 
 	mpt_read_ioc_pg_3(ioc);