* [PATCH 0/18] Use kmemdup instead of kmalloc + memcpy
@ 2014-05-26 15:21 Benoit Taine
2014-05-26 15:21 ` [PATCH 1/18] USB: storage: ene_ub6250: " Benoit Taine
` (17 more replies)
0 siblings, 18 replies; 30+ messages in thread
From: Benoit Taine @ 2014-05-26 15:21 UTC (permalink / raw)
To: linux-media
Cc: benoit.taine, dri-devel, devel, netdev, linux-wireless, wcn36xx,
linux-kernel, linux-usb, usb-storage, linux-scsi,
DL-MPTFusionLinux, linux-input, kernel-janitors
These patches enhance kernel style usage, and allows smaller code while
preventing accidental code edits to produce overflows.
The semantic patch at scripts/coccinelle/api/memdup.cocci was used to
detect and edit this situation.
^ permalink raw reply [flat|nested] 30+ messages in thread
* [PATCH 1/18] USB: storage: ene_ub6250: Use kmemdup instead of kmalloc + memcpy
2014-05-26 15:21 [PATCH 0/18] Use kmemdup instead of kmalloc + memcpy Benoit Taine
@ 2014-05-26 15:21 ` Benoit Taine
2014-05-26 15:21 ` [PATCH 3/18] VMCI: " Benoit Taine
` (16 subsequent siblings)
17 siblings, 0 replies; 30+ messages in thread
From: Benoit Taine @ 2014-05-26 15:21 UTC (permalink / raw)
To: Matthew Dharm
Cc: benoit.taine, Greg Kroah-Hartman, linux-usb, usb-storage,
linux-kernel, kernel-janitors
This issue was reported by coccicheck using the semantic patch
at scripts/coccinelle/api/memdup.cocci
Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
---
Tested by compilation without errors.
drivers/usb/storage/ene_ub6250.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/usb/storage/ene_ub6250.c b/drivers/usb/storage/ene_ub6250.c
index 1bfc9a6..ef6efb5 100644
--- a/drivers/usb/storage/ene_ub6250.c
+++ b/drivers/usb/storage/ene_ub6250.c
@@ -1928,11 +1928,10 @@ static int ene_load_bincode(struct us_data *us, unsigned char flag)
usb_stor_dbg(us, "load firmware %s failed\n", fw_name);
goto nofw;
}
- buf = kmalloc(sd_fw->size, GFP_KERNEL);
+ buf = kmemdup(sd_fw->data, sd_fw->size, GFP_KERNEL);
if (buf == NULL)
goto nofw;
- memcpy(buf, sd_fw->data, sd_fw->size);
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
bcb->DataTransferLength = sd_fw->size;
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 3/18] VMCI: Use kmemdup instead of kmalloc + memcpy
2014-05-26 15:21 [PATCH 0/18] Use kmemdup instead of kmalloc + memcpy Benoit Taine
2014-05-26 15:21 ` [PATCH 1/18] USB: storage: ene_ub6250: " Benoit Taine
@ 2014-05-26 15:21 ` Benoit Taine
2014-05-26 15:54 ` walter harms
2014-05-26 15:21 ` [PATCH 2/18] memstick: " Benoit Taine
` (15 subsequent siblings)
17 siblings, 1 reply; 30+ messages in thread
From: Benoit Taine @ 2014-05-26 15:21 UTC (permalink / raw)
To: linux-kernel; +Cc: benoit.taine, kernel-janitors
This issue was reported by coccicheck using the semantic patch
at scripts/coccinelle/api/memdup.cocci
Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
---
Tested by compilation without errors.
drivers/misc/vmw_vmci/vmci_datagram.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/misc/vmw_vmci/vmci_datagram.c b/drivers/misc/vmw_vmci/vmci_datagram.c
index f3cdd90..d93b469 100644
--- a/drivers/misc/vmw_vmci/vmci_datagram.c
+++ b/drivers/misc/vmw_vmci/vmci_datagram.c
@@ -276,11 +276,10 @@ static int dg_dispatch_as_host(u32 context_id, struct vmci_datagram *dg)
}
/* We make a copy to enqueue. */
- new_dg = kmalloc(dg_size, GFP_KERNEL);
+ new_dg = kmemdup(dg, dg_size, GFP_KERNEL);
if (new_dg == NULL)
return VMCI_ERROR_NO_MEM;
- memcpy(new_dg, dg, dg_size);
retval = vmci_ctx_enqueue_datagram(dg->dst.context, new_dg);
if (retval < VMCI_SUCCESS) {
kfree(new_dg);
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 2/18] memstick: Use kmemdup instead of kmalloc + memcpy
2014-05-26 15:21 [PATCH 0/18] Use kmemdup instead of kmalloc + memcpy Benoit Taine
2014-05-26 15:21 ` [PATCH 1/18] USB: storage: ene_ub6250: " Benoit Taine
2014-05-26 15:21 ` [PATCH 3/18] VMCI: " Benoit Taine
@ 2014-05-26 15:21 ` Benoit Taine
2014-05-26 15:21 ` [PATCH 4/18] qla4xxx: " Benoit Taine
` (14 subsequent siblings)
17 siblings, 0 replies; 30+ messages in thread
From: Benoit Taine @ 2014-05-26 15:21 UTC (permalink / raw)
To: linux-kernel; +Cc: benoit.taine, kernel-janitors
This issue was reported by coccicheck using the semantic patch
at scripts/coccinelle/api/memdup.cocci
Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
---
Tested by compilation without errors.
drivers/memstick/core/mspro_block.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/memstick/core/mspro_block.c b/drivers/memstick/core/mspro_block.c
index fc145d2..d52412d 100644
--- a/drivers/memstick/core/mspro_block.c
+++ b/drivers/memstick/core/mspro_block.c
@@ -1032,12 +1032,11 @@ static int mspro_block_read_attributes(struct memstick_dev *card)
}
msb->attr_group.name = "media_attributes";
- buffer = kmalloc(attr_len, GFP_KERNEL);
+ buffer = kmemdup((char *)attr, attr_len, GFP_KERNEL);
if (!buffer) {
rc = -ENOMEM;
goto out_free_attr;
}
- memcpy(buffer, (char *)attr, attr_len);
for (cnt = 0; cnt < attr_count; ++cnt) {
s_attr = kzalloc(sizeof(struct mspro_sys_attr), GFP_KERNEL);
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 4/18] qla4xxx: Use kmemdup instead of kmalloc + memcpy
2014-05-26 15:21 [PATCH 0/18] Use kmemdup instead of kmalloc + memcpy Benoit Taine
` (2 preceding siblings ...)
2014-05-26 15:21 ` [PATCH 2/18] memstick: " Benoit Taine
@ 2014-05-26 15:21 ` Benoit Taine
2014-05-27 8:38 ` Vikas Chaudhary
2014-05-26 15:21 ` [PATCH 5/18] wcn36xx: " Benoit Taine
` (13 subsequent siblings)
17 siblings, 1 reply; 30+ messages in thread
From: Benoit Taine @ 2014-05-26 15:21 UTC (permalink / raw)
To: Vikas Chaudhary
Cc: benoit.taine, iscsi-driver, James E.J. Bottomley, linux-scsi,
linux-kernel, kernel-janitors
This issue was reported by coccicheck using the semantic patch
at scripts/coccinelle/api/memdup.cocci
Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
---
Tested by compilation without errors.
drivers/scsi/qla4xxx/ql4_os.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
index 9eef7d4..3202063 100644
--- a/drivers/scsi/qla4xxx/ql4_os.c
+++ b/drivers/scsi/qla4xxx/ql4_os.c
@@ -3565,14 +3565,13 @@ static int qla4xxx_copy_from_fwddb_param(struct iscsi_bus_flash_session *sess,
if (test_bit(OPT_IPV6_DEVICE, &options)) {
conn->ipv6_traffic_class = fw_ddb_entry->ipv4_tos;
- conn->link_local_ipv6_addr = kzalloc(IPv6_ADDR_LEN, GFP_KERNEL);
+ conn->link_local_ipv6_addr = kmemdup(
+ fw_ddb_entry->link_local_ipv6_addr,
+ IPv6_ADDR_LEN, GFP_KERNEL);
if (!conn->link_local_ipv6_addr) {
rc = -ENOMEM;
goto exit_copy;
}
-
- memcpy(conn->link_local_ipv6_addr,
- fw_ddb_entry->link_local_ipv6_addr, IPv6_ADDR_LEN);
} else {
conn->ipv4_tos = fw_ddb_entry->ipv4_tos;
}
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 5/18] wcn36xx: Use kmemdup instead of kmalloc + memcpy
2014-05-26 15:21 [PATCH 0/18] Use kmemdup instead of kmalloc + memcpy Benoit Taine
` (3 preceding siblings ...)
2014-05-26 15:21 ` [PATCH 4/18] qla4xxx: " Benoit Taine
@ 2014-05-26 15:21 ` Benoit Taine
2014-05-26 15:21 ` [PATCH 6/18] fusion: " Benoit Taine
` (12 subsequent siblings)
17 siblings, 0 replies; 30+ messages in thread
From: Benoit Taine @ 2014-05-26 15:21 UTC (permalink / raw)
To: Eugene Krasnikov
Cc: benoit.taine, John W. Linville, wcn36xx, linux-wireless, netdev,
linux-kernel, kernel-janitors
This issue was reported by coccicheck using the semantic patch
at scripts/coccinelle/api/memdup.cocci
Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
---
Tested by compilation without errors.
drivers/net/wireless/ath/wcn36xx/smd.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/net/wireless/ath/wcn36xx/smd.c b/drivers/net/wireless/ath/wcn36xx/smd.c
index 7bf0ef8..6398693 100644
--- a/drivers/net/wireless/ath/wcn36xx/smd.c
+++ b/drivers/net/wireless/ath/wcn36xx/smd.c
@@ -2068,7 +2068,7 @@ static void wcn36xx_smd_rsp_process(struct wcn36xx *wcn, void *buf, size_t len)
if (!msg_ind)
goto nomem;
msg_ind->msg_len = len;
- msg_ind->msg = kmalloc(len, GFP_KERNEL);
+ msg_ind->msg = kmemdup(buf, len, GFP_KERNEL);
if (!msg_ind->msg) {
kfree(msg_ind);
nomem:
@@ -2080,7 +2080,6 @@ nomem:
msg_header->msg_type);
break;
}
- memcpy(msg_ind->msg, buf, len);
mutex_lock(&wcn->hal_ind_mutex);
list_add_tail(&msg_ind->list, &wcn->hal_ind_queue);
queue_work(wcn->hal_ind_wq, &wcn->hal_ind_work);
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 6/18] fusion: Use kmemdup instead of kmalloc + memcpy
2014-05-26 15:21 [PATCH 0/18] Use kmemdup instead of kmalloc + memcpy Benoit Taine
` (4 preceding siblings ...)
2014-05-26 15:21 ` [PATCH 5/18] wcn36xx: " Benoit Taine
@ 2014-05-26 15:21 ` Benoit Taine
2014-05-26 15:21 ` [PATCH 7/18] qla2xxx: " Benoit Taine
` (11 subsequent siblings)
17 siblings, 0 replies; 30+ messages in thread
From: Benoit Taine @ 2014-05-26 15:21 UTC (permalink / raw)
To: Nagalakshmi Nandigama
Cc: benoit.taine, Sreekanth Reddy, support, DL-MPTFusionLinux,
linux-scsi, linux-kernel, kernel-janitors
This issue was reported by coccicheck using the semantic patch
at scripts/coccinelle/api/memdup.cocci
Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
---
Tested by compilation without errors.
drivers/message/fusion/mptbase.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 570b18a..6417a3f 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -6004,13 +6004,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);
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 7/18] qla2xxx: Use kmemdup instead of kmalloc + memcpy
2014-05-26 15:21 [PATCH 0/18] Use kmemdup instead of kmalloc + memcpy Benoit Taine
` (5 preceding siblings ...)
2014-05-26 15:21 ` [PATCH 6/18] fusion: " Benoit Taine
@ 2014-05-26 15:21 ` Benoit Taine
2014-05-27 5:01 ` Saurav Kashyap
2014-05-26 15:21 ` [PATCH 8/18] Drivers: scsi: " Benoit Taine
` (10 subsequent siblings)
17 siblings, 1 reply; 30+ messages in thread
From: Benoit Taine @ 2014-05-26 15:21 UTC (permalink / raw)
To: qla2xxx-upstream
Cc: benoit.taine, James E.J. Bottomley, linux-scsi, linux-kernel,
kernel-janitors
This issue was reported by coccicheck using the semantic patch
at scripts/coccinelle/api/memdup.cocci
Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
---
Tested by compilation without errors.
drivers/scsi/qla2xxx/qla_mbx.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
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);
}
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 8/18] Drivers: scsi: Use kmemdup instead of kmalloc + memcpy
2014-05-26 15:21 [PATCH 0/18] Use kmemdup instead of kmalloc + memcpy Benoit Taine
` (6 preceding siblings ...)
2014-05-26 15:21 ` [PATCH 7/18] qla2xxx: " Benoit Taine
@ 2014-05-26 15:21 ` Benoit Taine
2014-05-26 15:21 ` [PATCH 9/18] staging: rtl8723au: " Benoit Taine
` (9 subsequent siblings)
17 siblings, 0 replies; 30+ messages in thread
From: Benoit Taine @ 2014-05-26 15:21 UTC (permalink / raw)
To: Nagalakshmi Nandigama
Cc: benoit.taine, Sreekanth Reddy, support, James E.J. Bottomley,
DL-MPTFusionLinux, linux-scsi, linux-kernel, kernel-janitors
This issue was reported by coccicheck using the semantic patch
at scripts/coccinelle/api/memdup.cocci
Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
---
Tested by compilation without errors.
drivers/scsi/mpt2sas/mpt2sas_scsih.c | 4 +---
drivers/scsi/mpt3sas/mpt3sas_scsih.c | 3 +--
2 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/scsi/mpt2sas/mpt2sas_scsih.c b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
index 6fd7d40..080d5f5 100644
--- a/drivers/scsi/mpt2sas/mpt2sas_scsih.c
+++ b/drivers/scsi/mpt2sas/mpt2sas_scsih.c
@@ -7603,7 +7603,7 @@ mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index,
return;
}
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__);
@@ -7611,8 +7611,6 @@ mpt2sas_scsih_event_callback(struct MPT2SAS_ADAPTER *ioc, u8 msix_index,
return;
}
- 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;
diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index a961fe1..40c15cf 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -7205,7 +7205,7 @@ mpt3sas_scsih_event_callback(struct MPT3SAS_ADAPTER *ioc, u8 msix_index,
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) {
pr_err(MPT3SAS_FMT "failure at %s:%d/%s()!\n",
ioc->name, __FILE__, __LINE__, __func__);
@@ -7213,7 +7213,6 @@ mpt3sas_scsih_event_callback(struct MPT3SAS_ADAPTER *ioc, u8 msix_index,
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;
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 9/18] staging: rtl8723au: Use kmemdup instead of kmalloc + memcpy
2014-05-26 15:21 [PATCH 0/18] Use kmemdup instead of kmalloc + memcpy Benoit Taine
` (7 preceding siblings ...)
2014-05-26 15:21 ` [PATCH 8/18] Drivers: scsi: " Benoit Taine
@ 2014-05-26 15:21 ` Benoit Taine
2014-05-26 15:43 ` Jes Sorensen
2014-05-26 15:21 ` [PATCH 10/18] aacraid: " Benoit Taine
` (8 subsequent siblings)
17 siblings, 1 reply; 30+ messages in thread
From: Benoit Taine @ 2014-05-26 15:21 UTC (permalink / raw)
To: Larry Finger
Cc: benoit.taine, Jes Sorensen, Greg Kroah-Hartman, linux-wireless,
devel, linux-kernel, kernel-janitors
This issue was reported by coccicheck using the semantic patch
at scripts/coccinelle/api/memdup.cocci
Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
---
Tested by compilation without errors.
drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 3 +--
drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 16 ++++++----------
2 files changed, 7 insertions(+), 12 deletions(-)
diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
index e2d426a..f917edd 100644
--- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
+++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
@@ -339,12 +339,11 @@ int rtl8723a_FirmwareDownload(struct rtw_adapter *padapter)
rtStatus = _FAIL;
goto Exit;
}
- firmware_buf = kzalloc(fw->size, GFP_KERNEL);
+ firmware_buf = kmemdup(fw->data, fw->size, GFP_KERNEL);
if (!firmware_buf) {
rtStatus = _FAIL;
goto Exit;
}
- memcpy(firmware_buf, fw->data, fw->size);
buf = firmware_buf;
fw_size = fw->size;
release_firmware(fw);
diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
index 182f57c..735eb99 100644
--- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
+++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
@@ -1426,14 +1426,13 @@ static int rtw_cfg80211_set_probe_req_wpsp2pie(struct rtw_adapter *padapter,
pmlmepriv->wps_probe_req_ie = NULL;
}
- pmlmepriv->wps_probe_req_ie =
- kmalloc(wps_ielen, GFP_KERNEL);
+ pmlmepriv->wps_probe_req_ie = kmemdup(wps_ie,
+ wps_ielen, GFP_KERNEL);
if (pmlmepriv->wps_probe_req_ie == NULL) {
DBG_8723A("%s()-%d: kmalloc() ERROR!\n",
__func__, __LINE__);
return -EINVAL;
}
- memcpy(pmlmepriv->wps_probe_req_ie, wps_ie, wps_ielen);
pmlmepriv->wps_probe_req_ie_len = wps_ielen;
}
}
@@ -1697,12 +1696,11 @@ static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie,
ret = -EINVAL;
goto exit;
}
- buf = kzalloc(ielen, GFP_KERNEL);
+ buf = kmemdup(pie, ielen, GFP_KERNEL);
if (buf == NULL) {
ret = -ENOMEM;
goto exit;
}
- memcpy(buf, pie, ielen);
/* dump */
DBG_8723A("set wpa_ie(length:%zu):\n", ielen);
@@ -3178,14 +3176,13 @@ static int rtw_cfg80211_set_beacon_wpsp2pie(struct net_device *ndev, char *buf,
pmlmepriv->wps_beacon_ie = NULL;
}
- pmlmepriv->wps_beacon_ie =
- kmalloc(wps_ielen, GFP_KERNEL);
+ pmlmepriv->wps_beacon_ie = kmemdup(wps_ie, wps_ielen,
+ GFP_KERNEL);
if (pmlmepriv->wps_beacon_ie == NULL) {
DBG_8723A("%s()-%d: kmalloc() ERROR!\n",
__func__, __LINE__);
return -EINVAL;
}
- memcpy(pmlmepriv->wps_beacon_ie, wps_ie, wps_ielen);
pmlmepriv->wps_beacon_ie_len = wps_ielen;
#ifdef CONFIG_8723AU_AP_MODE
@@ -3270,14 +3267,13 @@ static int rtw_cfg80211_set_assoc_resp_wpsp2pie(struct net_device *net,
pmlmepriv->wps_assoc_resp_ie = NULL;
}
- pmlmepriv->wps_assoc_resp_ie = kmalloc(len, GFP_KERNEL);
+ pmlmepriv->wps_assoc_resp_ie = kmemdup(buf, len, GFP_KERNEL);
if (pmlmepriv->wps_assoc_resp_ie == NULL) {
DBG_8723A("%s()-%d: kmalloc() ERROR!\n",
__func__, __LINE__);
return -EINVAL;
}
- memcpy(pmlmepriv->wps_assoc_resp_ie, buf, len);
pmlmepriv->wps_assoc_resp_ie_len = len;
}
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 10/18] aacraid: Use kmemdup instead of kmalloc + memcpy
2014-05-26 15:21 [PATCH 0/18] Use kmemdup instead of kmalloc + memcpy Benoit Taine
` (8 preceding siblings ...)
2014-05-26 15:21 ` [PATCH 9/18] staging: rtl8723au: " Benoit Taine
@ 2014-05-26 15:21 ` Benoit Taine
2014-05-26 15:21 ` [PATCH 11/18] usb: gadget: " Benoit Taine
` (7 subsequent siblings)
17 siblings, 0 replies; 30+ messages in thread
From: Benoit Taine @ 2014-05-26 15:21 UTC (permalink / raw)
To: Adaptec OEM Raid Solutions
Cc: benoit.taine, James E.J. Bottomley, linux-scsi, linux-kernel,
kernel-janitors
This issue was reported by coccicheck using the semantic patch
at scripts/coccinelle/api/memdup.cocci
Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
---
Tested by compilation without errors.
drivers/scsi/aacraid/commctrl.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/scsi/aacraid/commctrl.c b/drivers/scsi/aacraid/commctrl.c
index fbcd48d..0cdb16b 100644
--- a/drivers/scsi/aacraid/commctrl.c
+++ b/drivers/scsi/aacraid/commctrl.c
@@ -635,15 +635,14 @@ static int aac_send_raw_srb(struct aac_dev* dev, void __user * arg)
}
} else {
struct user_sgmap* usg;
- usg = kmalloc(actual_fibsize - sizeof(struct aac_srb)
- + sizeof(struct sgmap), GFP_KERNEL);
+ usg = kmemdup(upsg, actual_fibsize -
+ sizeof(struct aac_srb) + sizeof(struct sgmap),
+ GFP_KERNEL);
if (!usg) {
dprintk((KERN_DEBUG"aacraid: Allocation error in Raw SRB command\n"));
rcode = -ENOMEM;
goto cleanup;
}
- memcpy (usg, upsg, actual_fibsize - sizeof(struct aac_srb)
- + sizeof(struct sgmap));
actual_fibsize = actual_fibsize64;
for (i = 0; i < usg->count; i++) {
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 11/18] usb: gadget: Use kmemdup instead of kmalloc + memcpy
2014-05-26 15:21 [PATCH 0/18] Use kmemdup instead of kmalloc + memcpy Benoit Taine
` (9 preceding siblings ...)
2014-05-26 15:21 ` [PATCH 10/18] aacraid: " Benoit Taine
@ 2014-05-26 15:21 ` Benoit Taine
2014-05-26 15:21 ` [PATCH 12/18] aic7xxx: " Benoit Taine
` (6 subsequent siblings)
17 siblings, 0 replies; 30+ messages in thread
From: Benoit Taine @ 2014-05-26 15:21 UTC (permalink / raw)
To: Felipe Balbi
Cc: benoit.taine, Greg Kroah-Hartman, linux-usb, linux-kernel,
kernel-janitors
This issue was reported by coccicheck using the semantic patch
at scripts/coccinelle/api/memdup.cocci
Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
---
Tested by compilation without errors.
drivers/usb/gadget/configfs.c | 4 +---
drivers/usb/gadget/lpc32xx_udc.c | 3 +--
2 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/usb/gadget/configfs.c b/drivers/usb/gadget/configfs.c
index 2ddcd63..bcc2a62 100644
--- a/drivers/usb/gadget/configfs.c
+++ b/drivers/usb/gadget/configfs.c
@@ -1021,12 +1021,10 @@ static ssize_t ext_prop_data_store(struct usb_os_desc_ext_prop *ext_prop,
if (page[len - 1] == '\n' || page[len - 1] == '\0')
--len;
- new_data = kzalloc(len, GFP_KERNEL);
+ new_data = kmemdup(page, len, GFP_KERNEL);
if (!new_data)
return -ENOMEM;
- memcpy(new_data, page, len);
-
if (desc->opts_mutex)
mutex_lock(desc->opts_mutex);
kfree(ext_prop->data);
diff --git a/drivers/usb/gadget/lpc32xx_udc.c b/drivers/usb/gadget/lpc32xx_udc.c
index e471580..0588231 100644
--- a/drivers/usb/gadget/lpc32xx_udc.c
+++ b/drivers/usb/gadget/lpc32xx_udc.c
@@ -3045,11 +3045,10 @@ static int __init lpc32xx_udc_probe(struct platform_device *pdev)
dma_addr_t dma_handle;
struct device_node *isp1301_node;
- udc = kzalloc(sizeof(*udc), GFP_KERNEL);
+ udc = kmemdup(&controller_template, sizeof(*udc), GFP_KERNEL);
if (!udc)
return -ENOMEM;
- memcpy(udc, &controller_template, sizeof(*udc));
for (i = 0; i <= 15; i++)
udc->ep[i].udc = udc;
udc->gadget.ep0 = &udc->ep[0].ep;
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 12/18] aic7xxx: Use kmemdup instead of kmalloc + memcpy
2014-05-26 15:21 [PATCH 0/18] Use kmemdup instead of kmalloc + memcpy Benoit Taine
` (10 preceding siblings ...)
2014-05-26 15:21 ` [PATCH 11/18] usb: gadget: " Benoit Taine
@ 2014-05-26 15:21 ` Benoit Taine
2014-05-26 15:21 ` [PATCH 13/18] drm/edid: " Benoit Taine
` (5 subsequent siblings)
17 siblings, 0 replies; 30+ messages in thread
From: Benoit Taine @ 2014-05-26 15:21 UTC (permalink / raw)
To: Hannes Reinecke
Cc: benoit.taine, James E.J. Bottomley, linux-scsi, linux-kernel,
kernel-janitors
This issue was reported by coccicheck using the semantic patch
at scripts/coccinelle/api/memdup.cocci
Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
---
Tested by compilation without errors.
drivers/scsi/aic7xxx/aic79xx_core.c | 4 ++--
drivers/scsi/aic7xxx/aic7xxx_core.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/scsi/aic7xxx/aic79xx_core.c b/drivers/scsi/aic7xxx/aic79xx_core.c
index 0bcacf7..01353b1 100644
--- a/drivers/scsi/aic7xxx/aic79xx_core.c
+++ b/drivers/scsi/aic7xxx/aic79xx_core.c
@@ -9494,10 +9494,10 @@ ahd_loadseq(struct ahd_softc *ahd)
if (cs_count != 0) {
cs_count *= sizeof(struct cs);
- ahd->critical_sections = kmalloc(cs_count, GFP_ATOMIC);
+ ahd->critical_sections = kmemdup(cs_table, cs_count,
+ GFP_ATOMIC);
if (ahd->critical_sections == NULL)
panic("ahd_loadseq: Could not malloc");
- memcpy(ahd->critical_sections, cs_table, cs_count);
}
ahd_outb(ahd, SEQCTL0, PERRORDIS|FAILDIS|FASTMODE);
diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c
index 10172a3..f09337a 100644
--- a/drivers/scsi/aic7xxx/aic7xxx_core.c
+++ b/drivers/scsi/aic7xxx/aic7xxx_core.c
@@ -6941,10 +6941,10 @@ ahc_loadseq(struct ahc_softc *ahc)
if (cs_count != 0) {
cs_count *= sizeof(struct cs);
- ahc->critical_sections = kmalloc(cs_count, GFP_ATOMIC);
+ ahc->critical_sections = kmemdup(cs_table, cs_count,
+ GFP_ATOMIC);
if (ahc->critical_sections == NULL)
panic("ahc_loadseq: Could not malloc");
- memcpy(ahc->critical_sections, cs_table, cs_count);
}
ahc_outb(ahc, SEQCTL, PERRORDIS|FAILDIS|FASTMODE);
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 13/18] drm/edid: Use kmemdup instead of kmalloc + memcpy
2014-05-26 15:21 [PATCH 0/18] Use kmemdup instead of kmalloc + memcpy Benoit Taine
` (11 preceding siblings ...)
2014-05-26 15:21 ` [PATCH 12/18] aic7xxx: " Benoit Taine
@ 2014-05-26 15:21 ` Benoit Taine
2014-05-27 6:40 ` Jani Nikula
2014-05-27 15:14 ` Alex Deucher
2014-05-26 15:21 ` [PATCH 14/18] r8152: " Benoit Taine
` (4 subsequent siblings)
17 siblings, 2 replies; 30+ messages in thread
From: Benoit Taine @ 2014-05-26 15:21 UTC (permalink / raw)
To: David Airlie; +Cc: benoit.taine, dri-devel, linux-kernel, kernel-janitors
This issue was reported by coccicheck using the semantic patch
at scripts/coccinelle/api/memdup.cocci
Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
---
Tested by compilation without errors.
drivers/gpu/drm/drm_edid.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 7a4fd2e..d74239f 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -3228,10 +3228,9 @@ int drm_edid_to_speaker_allocation(struct edid *edid, u8 **sadb)
/* Speaker Allocation Data Block */
if (dbl == 3) {
- *sadb = kmalloc(dbl, GFP_KERNEL);
+ *sadb = kmemdup(&db[1], dbl, GFP_KERNEL);
if (!*sadb)
return -ENOMEM;
- memcpy(*sadb, &db[1], dbl);
count = dbl;
break;
}
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 14/18] r8152: Use kmemdup instead of kmalloc + memcpy
2014-05-26 15:21 [PATCH 0/18] Use kmemdup instead of kmalloc + memcpy Benoit Taine
` (12 preceding siblings ...)
2014-05-26 15:21 ` [PATCH 13/18] drm/edid: " Benoit Taine
@ 2014-05-26 15:21 ` Benoit Taine
2014-05-30 23:25 ` David Miller
2014-05-26 15:21 ` [PATCH 15/18] Drivers: media: " Benoit Taine
` (3 subsequent siblings)
17 siblings, 1 reply; 30+ messages in thread
From: Benoit Taine @ 2014-05-26 15:21 UTC (permalink / raw)
To: linux-usb; +Cc: benoit.taine, netdev, linux-kernel, kernel-janitors
This issue was reported by coccicheck using the semantic patch
at scripts/coccinelle/api/memdup.cocci
Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
---
Tested by compilation without errors.
drivers/net/usb/r8152.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index 9f91c7a..2543196 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -630,12 +630,10 @@ int set_registers(struct r8152 *tp, u16 value, u16 index, u16 size, void *data)
int ret;
void *tmp;
- tmp = kmalloc(size, GFP_KERNEL);
+ tmp = kmemdup(data, size, GFP_KERNEL);
if (!tmp)
return -ENOMEM;
- memcpy(tmp, data, size);
-
ret = usb_control_msg(tp->udev, usb_sndctrlpipe(tp->udev, 0),
RTL8152_REQ_SET_REGS, RTL8152_REQT_WRITE,
value, index, tmp, size, 500);
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 15/18] Drivers: media: Use kmemdup instead of kmalloc + memcpy
2014-05-26 15:21 [PATCH 0/18] Use kmemdup instead of kmalloc + memcpy Benoit Taine
` (13 preceding siblings ...)
2014-05-26 15:21 ` [PATCH 14/18] r8152: " Benoit Taine
@ 2014-05-26 15:21 ` Benoit Taine
2014-05-26 15:21 ` [PATCH 16/18] HID: uhid: " Benoit Taine
` (2 subsequent siblings)
17 siblings, 0 replies; 30+ messages in thread
From: Benoit Taine @ 2014-05-26 15:21 UTC (permalink / raw)
To: Guennadi Liakhovetski
Cc: benoit.taine, Mauro Carvalho Chehab, linux-media, linux-kernel,
kernel-janitors
This issue was reported by coccicheck using the semantic patch
at scripts/coccinelle/api/memdup.cocci
Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
---
Tested by compilation without errors.
drivers/media/platform/soc_camera/soc_camera.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
index c8549bf..8646c11 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -1346,13 +1346,11 @@ static int soc_camera_i2c_init(struct soc_camera_device *icd,
return -ENODEV;
}
- ssdd = kzalloc(sizeof(*ssdd), GFP_KERNEL);
+ ssdd = kmemdup(&sdesc->subdev_desc, sizeof(*ssdd), GFP_KERNEL);
if (!ssdd) {
ret = -ENOMEM;
goto ealloc;
}
-
- memcpy(ssdd, &sdesc->subdev_desc, sizeof(*ssdd));
/*
* In synchronous case we request regulators ourselves in
* soc_camera_pdrv_probe(), make sure the subdevice driver doesn't try
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 16/18] HID: uhid: Use kmemdup instead of kmalloc + memcpy
2014-05-26 15:21 [PATCH 0/18] Use kmemdup instead of kmalloc + memcpy Benoit Taine
` (14 preceding siblings ...)
2014-05-26 15:21 ` [PATCH 15/18] Drivers: media: " Benoit Taine
@ 2014-05-26 15:21 ` Benoit Taine
2014-05-26 15:33 ` David Herrmann
2014-05-26 22:42 ` Jiri Kosina
2014-05-26 15:21 ` [PATCH 17/18] drx-j: " Benoit Taine
2014-05-26 15:21 ` [PATCH 18/18] pinctrl: pinconf-generic: " Benoit Taine
17 siblings, 2 replies; 30+ messages in thread
From: Benoit Taine @ 2014-05-26 15:21 UTC (permalink / raw)
To: David Herrmann
Cc: benoit.taine, Jiri Kosina, linux-input, linux-kernel, kernel-janitors
This issue was reported by coccicheck using the semantic patch
at scripts/coccinelle/api/memdup.cocci
Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
---
Tested by compilation without errors.
drivers/hid/uhid.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
index 0d078c3..0cb92e3 100644
--- a/drivers/hid/uhid.c
+++ b/drivers/hid/uhid.c
@@ -441,12 +441,11 @@ static int uhid_dev_create2(struct uhid_device *uhid,
if (uhid->rd_size <= 0 || uhid->rd_size > HID_MAX_DESCRIPTOR_SIZE)
return -EINVAL;
- uhid->rd_data = kmalloc(uhid->rd_size, GFP_KERNEL);
+ uhid->rd_data = kmemdup(ev->u.create2.rd_data, uhid->rd_size,
+ GFP_KERNEL);
if (!uhid->rd_data)
return -ENOMEM;
- memcpy(uhid->rd_data, ev->u.create2.rd_data, uhid->rd_size);
-
hid = hid_allocate_device();
if (IS_ERR(hid)) {
ret = PTR_ERR(hid);
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 17/18] drx-j: Use kmemdup instead of kmalloc + memcpy
2014-05-26 15:21 [PATCH 0/18] Use kmemdup instead of kmalloc + memcpy Benoit Taine
` (15 preceding siblings ...)
2014-05-26 15:21 ` [PATCH 16/18] HID: uhid: " Benoit Taine
@ 2014-05-26 15:21 ` Benoit Taine
2014-05-26 15:21 ` [PATCH 18/18] pinctrl: pinconf-generic: " Benoit Taine
17 siblings, 0 replies; 30+ messages in thread
From: Benoit Taine @ 2014-05-26 15:21 UTC (permalink / raw)
To: Mauro Carvalho Chehab
Cc: benoit.taine, linux-media, linux-kernel, kernel-janitors
This issue was reported by coccicheck using the semantic patch
at scripts/coccinelle/api/memdup.cocci
Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
---
Not compile tested.
drivers/media/dvb-frontends/drx39xyj/drxj.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/media/dvb-frontends/drx39xyj/drxj.c b/drivers/media/dvb-frontends/drx39xyj/drxj.c
index 9482954..3795f65 100644
--- a/drivers/media/dvb-frontends/drx39xyj/drxj.c
+++ b/drivers/media/dvb-frontends/drx39xyj/drxj.c
@@ -12272,22 +12272,20 @@ struct dvb_frontend *drx39xxj_attach(struct i2c_adapter *i2c)
if (demod == NULL)
goto error;
- demod_addr = kmalloc(sizeof(struct i2c_device_addr), GFP_KERNEL);
+ demod_addr = kmemdup(&drxj_default_addr_g,
+ sizeof(struct i2c_device_addr), GFP_KERNEL);
if (demod_addr == NULL)
goto error;
- memcpy(demod_addr, &drxj_default_addr_g,
- sizeof(struct i2c_device_addr));
- demod_comm_attr = kmalloc(sizeof(struct drx_common_attr), GFP_KERNEL);
+ demod_comm_attr = kmemdup(&drxj_default_comm_attr_g,
+ sizeof(struct drx_common_attr), GFP_KERNEL);
if (demod_comm_attr == NULL)
goto error;
- memcpy(demod_comm_attr, &drxj_default_comm_attr_g,
- sizeof(struct drx_common_attr));
- demod_ext_attr = kmalloc(sizeof(struct drxj_data), GFP_KERNEL);
+ demod_ext_attr = kmemdup(&drxj_data_g, sizeof(struct drxj_data),
+ GFP_KERNEL);
if (demod_ext_attr == NULL)
goto error;
- memcpy(demod_ext_attr, &drxj_data_g, sizeof(struct drxj_data));
/* setup the state */
state->i2c = i2c;
^ permalink raw reply related [flat|nested] 30+ messages in thread
* [PATCH 18/18] pinctrl: pinconf-generic: Use kmemdup instead of kmalloc + memcpy
2014-05-26 15:21 [PATCH 0/18] Use kmemdup instead of kmalloc + memcpy Benoit Taine
` (16 preceding siblings ...)
2014-05-26 15:21 ` [PATCH 17/18] drx-j: " Benoit Taine
@ 2014-05-26 15:21 ` Benoit Taine
2014-05-27 14:06 ` Linus Walleij
17 siblings, 1 reply; 30+ messages in thread
From: Benoit Taine @ 2014-05-26 15:21 UTC (permalink / raw)
To: Linus Walleij; +Cc: benoit.taine, linux-kernel, kernel-janitors
This issue was reported by coccicheck using the semantic patch
at scripts/coccinelle/api/memdup.cocci
Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
---
Not compile tested, due incompatible architecture.
drivers/pinctrl/pinconf-generic.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/pinctrl/pinconf-generic.c b/drivers/pinctrl/pinconf-generic.c
index 3d9a999..2457ca9 100644
--- a/drivers/pinctrl/pinconf-generic.c
+++ b/drivers/pinctrl/pinconf-generic.c
@@ -228,13 +228,12 @@ int pinconf_generic_parse_dt_config(struct device_node *np,
* Now limit the number of configs to the real number of
* found properties.
*/
- *configs = kzalloc(ncfg * sizeof(unsigned long), GFP_KERNEL);
+ *configs = kmemdup(cfg, ncfg * sizeof(unsigned long), GFP_KERNEL);
if (!*configs) {
ret = -ENOMEM;
goto out;
}
- memcpy(*configs, cfg, ncfg * sizeof(unsigned long));
*nconfigs = ncfg;
out:
^ permalink raw reply related [flat|nested] 30+ messages in thread
* Re: [PATCH 16/18] HID: uhid: Use kmemdup instead of kmalloc + memcpy
2014-05-26 15:21 ` [PATCH 16/18] HID: uhid: " Benoit Taine
@ 2014-05-26 15:33 ` David Herrmann
2014-05-26 22:42 ` Jiri Kosina
1 sibling, 0 replies; 30+ messages in thread
From: David Herrmann @ 2014-05-26 15:33 UTC (permalink / raw)
To: Benoit Taine
Cc: David Herrmann, Jiri Kosina, open list:HID CORE LAYER,
linux-kernel, kernel-janitors
Hi
On Mon, May 26, 2014 at 5:21 PM, Benoit Taine <benoit.taine@lip6.fr> wrote:
> This issue was reported by coccicheck using the semantic patch
> at scripts/coccinelle/api/memdup.cocci
>
> Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
Reviewed-by: David Herrmann <dh.herrmann@gmail.com>
Thanks
David
> ---
> Tested by compilation without errors.
>
> drivers/hid/uhid.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
> index 0d078c3..0cb92e3 100644
> --- a/drivers/hid/uhid.c
> +++ b/drivers/hid/uhid.c
> @@ -441,12 +441,11 @@ static int uhid_dev_create2(struct uhid_device *uhid,
> if (uhid->rd_size <= 0 || uhid->rd_size > HID_MAX_DESCRIPTOR_SIZE)
> return -EINVAL;
>
> - uhid->rd_data = kmalloc(uhid->rd_size, GFP_KERNEL);
> + uhid->rd_data = kmemdup(ev->u.create2.rd_data, uhid->rd_size,
> + GFP_KERNEL);
> if (!uhid->rd_data)
> return -ENOMEM;
>
> - memcpy(uhid->rd_data, ev->u.create2.rd_data, uhid->rd_size);
> -
> hid = hid_allocate_device();
> if (IS_ERR(hid)) {
> ret = PTR_ERR(hid);
>
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 9/18] staging: rtl8723au: Use kmemdup instead of kmalloc + memcpy
2014-05-26 15:21 ` [PATCH 9/18] staging: rtl8723au: " Benoit Taine
@ 2014-05-26 15:43 ` Jes Sorensen
2014-05-26 15:57 ` Benoit Taine
0 siblings, 1 reply; 30+ messages in thread
From: Jes Sorensen @ 2014-05-26 15:43 UTC (permalink / raw)
To: Benoit Taine
Cc: Larry Finger, Greg Kroah-Hartman, linux-wireless, devel,
linux-kernel, kernel-janitors
Benoit Taine <benoit.taine@lip6.fr> writes:
> This issue was reported by coccicheck using the semantic patch
> at scripts/coccinelle/api/memdup.cocci
>
> Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
> ---
> Tested by compilation without errors.
>
> drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 3 +--
> drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 16 ++++++----------
> 2 files changed, 7 insertions(+), 12 deletions(-)
Benoit,
I believe this was already applied to staging-next - if you feel
something is missing. Could you please re-diff against the latest
staging-next tree.
Cheers,
Jes
commit 4a6eea4dcbc0328c3126fed264c42b0725bea659
Author: Benoit Taine <benoit.taine@lip6.fr>
Date: Thu May 22 15:08:33 2014 +0200
staging: rtl8723au: Use kmemdup() instead of memcpy() to duplicate memory
This issue was reported by coccicheck using the semantic patch
at scripts/coccinelle/api/memdup.cocci, and tested by compilation.
Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>
> diff --git a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
> index e2d426a..f917edd 100644
> --- a/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
> +++ b/drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c
> @@ -339,12 +339,11 @@ int rtl8723a_FirmwareDownload(struct rtw_adapter *padapter)
> rtStatus = _FAIL;
> goto Exit;
> }
> - firmware_buf = kzalloc(fw->size, GFP_KERNEL);
> + firmware_buf = kmemdup(fw->data, fw->size, GFP_KERNEL);
> if (!firmware_buf) {
> rtStatus = _FAIL;
> goto Exit;
> }
> - memcpy(firmware_buf, fw->data, fw->size);
> buf = firmware_buf;
> fw_size = fw->size;
> release_firmware(fw);
> diff --git a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
> index 182f57c..735eb99 100644
> --- a/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
> +++ b/drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c
> @@ -1426,14 +1426,13 @@ static int rtw_cfg80211_set_probe_req_wpsp2pie(struct rtw_adapter *padapter,
> pmlmepriv->wps_probe_req_ie = NULL;
> }
>
> - pmlmepriv->wps_probe_req_ie =
> - kmalloc(wps_ielen, GFP_KERNEL);
> + pmlmepriv->wps_probe_req_ie = kmemdup(wps_ie,
> + wps_ielen, GFP_KERNEL);
> if (pmlmepriv->wps_probe_req_ie == NULL) {
> DBG_8723A("%s()-%d: kmalloc() ERROR!\n",
> __func__, __LINE__);
> return -EINVAL;
> }
> - memcpy(pmlmepriv->wps_probe_req_ie, wps_ie, wps_ielen);
> pmlmepriv->wps_probe_req_ie_len = wps_ielen;
> }
> }
> @@ -1697,12 +1696,11 @@ static int rtw_cfg80211_set_wpa_ie(struct rtw_adapter *padapter, const u8 *pie,
> ret = -EINVAL;
> goto exit;
> }
> - buf = kzalloc(ielen, GFP_KERNEL);
> + buf = kmemdup(pie, ielen, GFP_KERNEL);
> if (buf == NULL) {
> ret = -ENOMEM;
> goto exit;
> }
> - memcpy(buf, pie, ielen);
>
> /* dump */
> DBG_8723A("set wpa_ie(length:%zu):\n", ielen);
> @@ -3178,14 +3176,13 @@ static int rtw_cfg80211_set_beacon_wpsp2pie(struct net_device *ndev, char *buf,
> pmlmepriv->wps_beacon_ie = NULL;
> }
>
> - pmlmepriv->wps_beacon_ie =
> - kmalloc(wps_ielen, GFP_KERNEL);
> + pmlmepriv->wps_beacon_ie = kmemdup(wps_ie, wps_ielen,
> + GFP_KERNEL);
> if (pmlmepriv->wps_beacon_ie == NULL) {
> DBG_8723A("%s()-%d: kmalloc() ERROR!\n",
> __func__, __LINE__);
> return -EINVAL;
> }
> - memcpy(pmlmepriv->wps_beacon_ie, wps_ie, wps_ielen);
> pmlmepriv->wps_beacon_ie_len = wps_ielen;
>
> #ifdef CONFIG_8723AU_AP_MODE
> @@ -3270,14 +3267,13 @@ static int rtw_cfg80211_set_assoc_resp_wpsp2pie(struct net_device *net,
> pmlmepriv->wps_assoc_resp_ie = NULL;
> }
>
> - pmlmepriv->wps_assoc_resp_ie = kmalloc(len, GFP_KERNEL);
> + pmlmepriv->wps_assoc_resp_ie = kmemdup(buf, len, GFP_KERNEL);
> if (pmlmepriv->wps_assoc_resp_ie == NULL) {
> DBG_8723A("%s()-%d: kmalloc() ERROR!\n",
> __func__, __LINE__);
> return -EINVAL;
>
> }
> - memcpy(pmlmepriv->wps_assoc_resp_ie, buf, len);
> pmlmepriv->wps_assoc_resp_ie_len = len;
> }
>
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 3/18] VMCI: Use kmemdup instead of kmalloc + memcpy
2014-05-26 15:21 ` [PATCH 3/18] VMCI: " Benoit Taine
@ 2014-05-26 15:54 ` walter harms
0 siblings, 0 replies; 30+ messages in thread
From: walter harms @ 2014-05-26 15:54 UTC (permalink / raw)
To: Benoit Taine; +Cc: linux-kernel, kernel-janitors
Am 26.05.2014 17:21, schrieb Benoit Taine:
> This issue was reported by coccicheck using the semantic patch
> at scripts/coccinelle/api/memdup.cocci
>
> Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
> ---
> Tested by compilation without errors.
>
> drivers/misc/vmw_vmci/vmci_datagram.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/misc/vmw_vmci/vmci_datagram.c b/drivers/misc/vmw_vmci/vmci_datagram.c
> index f3cdd90..d93b469 100644
> --- a/drivers/misc/vmw_vmci/vmci_datagram.c
> +++ b/drivers/misc/vmw_vmci/vmci_datagram.c
> @@ -276,11 +276,10 @@ static int dg_dispatch_as_host(u32 context_id, struct vmci_datagram *dg)
> }
>
> /* We make a copy to enqueue. */
> - new_dg = kmalloc(dg_size, GFP_KERNEL);
> + new_dg = kmemdup(dg, dg_size, GFP_KERNEL);
> if (new_dg == NULL)
> return VMCI_ERROR_NO_MEM;
i can not see much of the code but this looks like
new_dg=dg;
what is possible in c99.
re,
wh
>
> - memcpy(new_dg, dg, dg_size);
> retval = vmci_ctx_enqueue_datagram(dg->dst.context, new_dg);
> if (retval < VMCI_SUCCESS) {
> kfree(new_dg);
>
> --
> To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 9/18] staging: rtl8723au: Use kmemdup instead of kmalloc + memcpy
2014-05-26 15:43 ` Jes Sorensen
@ 2014-05-26 15:57 ` Benoit Taine
0 siblings, 0 replies; 30+ messages in thread
From: Benoit Taine @ 2014-05-26 15:57 UTC (permalink / raw)
To: Jes Sorensen
Cc: Larry Finger, Greg Kroah-Hartman, linux-wireless, devel,
linux-kernel, kernel-janitors
On 26/05/2014 17:43, Jes Sorensen wrote:
> Benoit Taine <benoit.taine@lip6.fr> writes:
> > This issue was reported by coccicheck using the semantic patch
> > at scripts/coccinelle/api/memdup.cocci
> >
> > Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
> > ---
> > Tested by compilation without errors.
> >
> > drivers/staging/rtl8723au/hal/rtl8723a_hal_init.c | 3 +--
> > drivers/staging/rtl8723au/os_dep/ioctl_cfg80211.c | 16 ++++++----------
> > 2 files changed, 7 insertions(+), 12 deletions(-)
>
> Benoit,
>
> I believe this was already applied to staging-next - if you feel
> something is missing. Could you please re-diff against the latest
> staging-next tree.
Agreed, it is mostly 80 chars per line compliance. I will resend.
--
Benoît Taine
Master cycle intern
Regal Team. LIP6
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 16/18] HID: uhid: Use kmemdup instead of kmalloc + memcpy
2014-05-26 15:21 ` [PATCH 16/18] HID: uhid: " Benoit Taine
2014-05-26 15:33 ` David Herrmann
@ 2014-05-26 22:42 ` Jiri Kosina
1 sibling, 0 replies; 30+ messages in thread
From: Jiri Kosina @ 2014-05-26 22:42 UTC (permalink / raw)
To: Benoit Taine; +Cc: David Herrmann, linux-input, linux-kernel, kernel-janitors
On Mon, 26 May 2014, Benoit Taine wrote:
> This issue was reported by coccicheck using the semantic patch
> at scripts/coccinelle/api/memdup.cocci
>
> Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
Applied, thanks Benoit.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 7/18] qla2xxx: Use kmemdup instead of kmalloc + memcpy
2014-05-26 15:21 ` [PATCH 7/18] qla2xxx: " Benoit Taine
@ 2014-05-27 5:01 ` Saurav Kashyap
0 siblings, 0 replies; 30+ messages in thread
From: Saurav Kashyap @ 2014-05-27 5:01 UTC (permalink / raw)
To: Benoit Taine, Chad Dupuis, Giridhar Malavali, Saurav Kashyap
Cc: James E.J. Bottomley, linux-scsi, linux-kernel, kernel-janitors
Acked-by: Saurav Kashyap <saurav.kashyap@qlogic.com>
>This issue was reported by coccicheck using the semantic patch
>at scripts/coccinelle/api/memdup.cocci
>
>Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
>---
>Tested by compilation without errors.
>
> drivers/scsi/qla2xxx/qla_mbx.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
>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);
> }
>
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 13/18] drm/edid: Use kmemdup instead of kmalloc + memcpy
2014-05-26 15:21 ` [PATCH 13/18] drm/edid: " Benoit Taine
@ 2014-05-27 6:40 ` Jani Nikula
2014-05-27 15:14 ` Alex Deucher
1 sibling, 0 replies; 30+ messages in thread
From: Jani Nikula @ 2014-05-27 6:40 UTC (permalink / raw)
To: Benoit Taine, David Airlie
Cc: benoit.taine, kernel-janitors, linux-kernel, dri-devel
On Mon, 26 May 2014, Benoit Taine <benoit.taine@lip6.fr> wrote:
> This issue was reported by coccicheck using the semantic patch
> at scripts/coccinelle/api/memdup.cocci
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
>
> Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
> ---
> Tested by compilation without errors.
>
> drivers/gpu/drm/drm_edid.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 7a4fd2e..d74239f 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -3228,10 +3228,9 @@ int drm_edid_to_speaker_allocation(struct edid *edid, u8 **sadb)
>
> /* Speaker Allocation Data Block */
> if (dbl == 3) {
> - *sadb = kmalloc(dbl, GFP_KERNEL);
> + *sadb = kmemdup(&db[1], dbl, GFP_KERNEL);
> if (!*sadb)
> return -ENOMEM;
> - memcpy(*sadb, &db[1], dbl);
> count = dbl;
> break;
> }
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
--
Jani Nikula, Intel Open Source Technology Center
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 4/18] qla4xxx: Use kmemdup instead of kmalloc + memcpy
2014-05-26 15:21 ` [PATCH 4/18] qla4xxx: " Benoit Taine
@ 2014-05-27 8:38 ` Vikas Chaudhary
0 siblings, 0 replies; 30+ messages in thread
From: Vikas Chaudhary @ 2014-05-27 8:38 UTC (permalink / raw)
To: Benoit Taine
Cc: Dept-Eng iSCSI Driver, James E.J. Bottomley, linux-scsi,
linux-kernel, kernel-janitors
On 26/05/14 8:51 pm, "Benoit Taine" <benoit.taine@lip6.fr> wrote:
>This issue was reported by coccicheck using the semantic patch
>at scripts/coccinelle/api/memdup.cocci
>
>Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
>---
>Tested by compilation without errors.
>
> drivers/scsi/qla4xxx/ql4_os.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
>diff --git a/drivers/scsi/qla4xxx/ql4_os.c b/drivers/scsi/qla4xxx/ql4_os.c
>index 9eef7d4..3202063 100644
>--- a/drivers/scsi/qla4xxx/ql4_os.c
>+++ b/drivers/scsi/qla4xxx/ql4_os.c
>@@ -3565,14 +3565,13 @@ static int qla4xxx_copy_from_fwddb_param(struct
>iscsi_bus_flash_session *sess,
> if (test_bit(OPT_IPV6_DEVICE, &options)) {
> conn->ipv6_traffic_class = fw_ddb_entry->ipv4_tos;
>
>- conn->link_local_ipv6_addr = kzalloc(IPv6_ADDR_LEN, GFP_KERNEL);
>+ conn->link_local_ipv6_addr = kmemdup(
>+ fw_ddb_entry->link_local_ipv6_addr,
>+ IPv6_ADDR_LEN, GFP_KERNEL);
> if (!conn->link_local_ipv6_addr) {
> rc = -ENOMEM;
> goto exit_copy;
> }
>-
>- memcpy(conn->link_local_ipv6_addr,
>- fw_ddb_entry->link_local_ipv6_addr, IPv6_ADDR_LEN);
> } else {
> conn->ipv4_tos = fw_ddb_entry->ipv4_tos;
> }
Acked-by: Vikas Chaudhary <vikas.chaudhary@qlogic.com>
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 18/18] pinctrl: pinconf-generic: Use kmemdup instead of kmalloc + memcpy
2014-05-26 15:21 ` [PATCH 18/18] pinctrl: pinconf-generic: " Benoit Taine
@ 2014-05-27 14:06 ` Linus Walleij
0 siblings, 0 replies; 30+ messages in thread
From: Linus Walleij @ 2014-05-27 14:06 UTC (permalink / raw)
To: Benoit Taine; +Cc: linux-kernel, kernel-janitors
On Mon, May 26, 2014 at 5:21 PM, Benoit Taine <benoit.taine@lip6.fr> wrote:
> This issue was reported by coccicheck using the semantic patch
> at scripts/coccinelle/api/memdup.cocci
>
> Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
> ---
> Not compile tested, due incompatible architecture.
Excellent fix, thanks. Patch applied.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 13/18] drm/edid: Use kmemdup instead of kmalloc + memcpy
2014-05-26 15:21 ` [PATCH 13/18] drm/edid: " Benoit Taine
2014-05-27 6:40 ` Jani Nikula
@ 2014-05-27 15:14 ` Alex Deucher
1 sibling, 0 replies; 30+ messages in thread
From: Alex Deucher @ 2014-05-27 15:14 UTC (permalink / raw)
To: Benoit Taine
Cc: David Airlie, kernel-janitors, LKML, Maling list - DRI developers
On Mon, May 26, 2014 at 11:21 AM, Benoit Taine <benoit.taine@lip6.fr> wrote:
> This issue was reported by coccicheck using the semantic patch
> at scripts/coccinelle/api/memdup.cocci
>
> Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
> ---
> Tested by compilation without errors.
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
>
> drivers/gpu/drm/drm_edid.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 7a4fd2e..d74239f 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -3228,10 +3228,9 @@ int drm_edid_to_speaker_allocation(struct edid *edid, u8 **sadb)
>
> /* Speaker Allocation Data Block */
> if (dbl == 3) {
> - *sadb = kmalloc(dbl, GFP_KERNEL);
> + *sadb = kmemdup(&db[1], dbl, GFP_KERNEL);
> if (!*sadb)
> return -ENOMEM;
> - memcpy(*sadb, &db[1], dbl);
> count = dbl;
> break;
> }
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 30+ messages in thread
* Re: [PATCH 14/18] r8152: Use kmemdup instead of kmalloc + memcpy
2014-05-26 15:21 ` [PATCH 14/18] r8152: " Benoit Taine
@ 2014-05-30 23:25 ` David Miller
0 siblings, 0 replies; 30+ messages in thread
From: David Miller @ 2014-05-30 23:25 UTC (permalink / raw)
To: benoit.taine; +Cc: linux-usb, netdev, linux-kernel, kernel-janitors
From: Benoit Taine <benoit.taine@lip6.fr>
Date: Mon, 26 May 2014 17:21:23 +0200
> This issue was reported by coccicheck using the semantic patch
> at scripts/coccinelle/api/memdup.cocci
>
> Signed-off-by: Benoit Taine <benoit.taine@lip6.fr>
> ---
> Tested by compilation without errors.
Applied to net-next, thank you.
^ permalink raw reply [flat|nested] 30+ messages in thread
end of thread, other threads:[~2014-05-30 23:25 UTC | newest]
Thread overview: 30+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-26 15:21 [PATCH 0/18] Use kmemdup instead of kmalloc + memcpy Benoit Taine
2014-05-26 15:21 ` [PATCH 1/18] USB: storage: ene_ub6250: " Benoit Taine
2014-05-26 15:21 ` [PATCH 3/18] VMCI: " Benoit Taine
2014-05-26 15:54 ` walter harms
2014-05-26 15:21 ` [PATCH 2/18] memstick: " Benoit Taine
2014-05-26 15:21 ` [PATCH 4/18] qla4xxx: " Benoit Taine
2014-05-27 8:38 ` Vikas Chaudhary
2014-05-26 15:21 ` [PATCH 5/18] wcn36xx: " Benoit Taine
2014-05-26 15:21 ` [PATCH 6/18] fusion: " Benoit Taine
2014-05-26 15:21 ` [PATCH 7/18] qla2xxx: " Benoit Taine
2014-05-27 5:01 ` Saurav Kashyap
2014-05-26 15:21 ` [PATCH 8/18] Drivers: scsi: " Benoit Taine
2014-05-26 15:21 ` [PATCH 9/18] staging: rtl8723au: " Benoit Taine
2014-05-26 15:43 ` Jes Sorensen
2014-05-26 15:57 ` Benoit Taine
2014-05-26 15:21 ` [PATCH 10/18] aacraid: " Benoit Taine
2014-05-26 15:21 ` [PATCH 11/18] usb: gadget: " Benoit Taine
2014-05-26 15:21 ` [PATCH 12/18] aic7xxx: " Benoit Taine
2014-05-26 15:21 ` [PATCH 13/18] drm/edid: " Benoit Taine
2014-05-27 6:40 ` Jani Nikula
2014-05-27 15:14 ` Alex Deucher
2014-05-26 15:21 ` [PATCH 14/18] r8152: " Benoit Taine
2014-05-30 23:25 ` David Miller
2014-05-26 15:21 ` [PATCH 15/18] Drivers: media: " Benoit Taine
2014-05-26 15:21 ` [PATCH 16/18] HID: uhid: " Benoit Taine
2014-05-26 15:33 ` David Herrmann
2014-05-26 22:42 ` Jiri Kosina
2014-05-26 15:21 ` [PATCH 17/18] drx-j: " Benoit Taine
2014-05-26 15:21 ` [PATCH 18/18] pinctrl: pinconf-generic: " Benoit Taine
2014-05-27 14:06 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).