From: Benoit Taine Date: Mon, 26 May 2014 15:21:16 +0000 (+0200) Subject: qla2xxx: Use kmemdup instead of kmalloc + memcpy X-Git-Tag: v4.14-rc1~7360^2~48 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c1818f17b58e416ec19653be430e9e2925cec35c;p=platform%2Fkernel%2Flinux-rpi.git qla2xxx: Use kmemdup instead of kmalloc + memcpy This issue was reported by coccicheck using the semantic patch at scripts/coccinelle/api/memdup.cocci Signed-off-by: Benoit Taine Acked-by: Saurav Kashyap Signed-off-by: Christoph Hellwig --- diff --git a/drivers/scsi/qla2xxx/qla_mbx.c b/drivers/scsi/qla2xxx/qla_mbx.c index 7f39e36..1c33a77 100644 --- a/drivers/scsi/qla2xxx/qla_mbx.c +++ b/drivers/scsi/qla2xxx/qla_mbx.c @@ -1319,7 +1319,7 @@ qla2x00_get_node_name_list(scsi_qla_host_t *vha, void **out_data, int *out_len) left = 0; - list = kzalloc(dma_size, GFP_KERNEL); + list = kmemdup(pmap, dma_size, GFP_KERNEL); if (!list) { ql_log(ql_log_warn, vha, 0x1140, "%s(%ld): failed to allocate node names list " @@ -1328,7 +1328,6 @@ qla2x00_get_node_name_list(scsi_qla_host_t *vha, void **out_data, int *out_len) goto out_free; } - memcpy(list, pmap, dma_size); restart: dma_free_coherent(&ha->pdev->dev, dma_size, pmap, pmap_dma); }