scsi: message: fusion: Use kmemdup instead of memcpy and kmalloc
authorBharath Vedartham <linux.bhar@gmail.com>
Wed, 22 May 2019 16:01:49 +0000 (21:31 +0530)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 18 Jun 2019 23:46:24 +0000 (19:46 -0400)
Replace kmalloc + memcpy with kmemdup.

This was reported by coccinelle.

Signed-off-by: Bharath Vedartham <linux.bhar@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/message/fusion/mptbase.c

index d8882b0..c2dd322 100644 (file)
@@ -6001,13 +6001,12 @@ mpt_findImVolumes(MPT_ADAPTER *ioc)
        if (mpt_config(ioc, &cfg) != 0)
                goto out;
 
-       mem = kmalloc(iocpage2sz, GFP_KERNEL);
+       mem = kmemdup(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);