[<prev] [next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.64.1005152319310.21345@ask.diku.dk>
Date: Sat, 15 May 2010 23:19:48 +0200 (CEST)
From: Julia Lawall <julia@...u.dk>
To: "James E.J. Bottomley" <James.Bottomley@...e.de>,
linux-scsi@...r.kernel.org, linux-kernel@...r.kernel.org,
kernel-janitors@...r.kernel.org
Subject: [PATCH 22/37] drivers/scsi/mpt2sas: Use kmemdup
From: Julia Lawall <julia@...u.dk>
Use kmemdup when some other buffer is immediately copied into the
allocated region.
A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@@
expression from,to,size,flag;
statement S;
@@
- to = \(kmalloc\|kzalloc\)(size,flag);
+ to = kmemdup(from,size,flag);
if (to==NULL || ...) S
- memcpy(to, from, size);
// </smpl>
Signed-off-by: Julia Lawall <julia@...u.dk>
---
drivers/scsi/mpt2sas/mpt2sas_scsih.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff -u -p a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
@@ -6056,7 +6056,7 @@ mpt2sas_scsih_event_callback(struct MPT2
return 1;
}
sz = le16_to_cpu(mpi_reply->EventDataLength) * 4;
- fw_event->event_data = kzalloc(sz, GFP_ATOMIC);
+ fw_event->event_data = kmemdup(mpi_reply->EventData, sz, GFP_ATOMIC);
if (!fw_event->event_data) {
printk(MPT2SAS_ERR_FMT "failure at %s:%d/%s()!\n",
ioc->name, __FILE__, __LINE__, __func__);
@@ -6064,8 +6064,6 @@ mpt2sas_scsih_event_callback(struct MPT2
return 1;
}
- memcpy(fw_event->event_data, mpi_reply->EventData,
- sz);
fw_event->ioc = ioc;
fw_event->VF_ID = mpi_reply->VF_ID;
fw_event->VP_ID = mpi_reply->VP_ID;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists