* [PATCH] staging: wilc1000: use kmemdup instead of kmalloc and memcpy
@ 2018-03-13 6:20 ` hariprasath.elango
0 siblings, 0 replies; 6+ messages in thread
From: hariprasath.elango @ 2018-03-13 6:20 UTC (permalink / raw)
To: aditya.shankar
Cc: hariprasath.elango, vbabu3, Ganesh Krishna, Greg Kroah-Hartman,
linux-wireless, devel, linux-kernel
From: HariPrasath Elango <hariprasath.elango@gmail.com>
Kmalloc followed by memcpy can be replaced by kmemdup.
Signed-off-by: HariPrasath Elango <hariprasath.elango@gmail.com>
---
drivers/staging/wilc1000/linux_mon.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/staging/wilc1000/linux_mon.c b/drivers/staging/wilc1000/linux_mon.c
index f93f411..c6fd6b3 100644
--- a/drivers/staging/wilc1000/linux_mon.c
+++ b/drivers/staging/wilc1000/linux_mon.c
@@ -146,7 +146,7 @@ static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len)
if (!mgmt_tx)
return -ENOMEM;
- mgmt_tx->buff = kmalloc(len, GFP_ATOMIC);
+ mgmt_tx->buff = kmemdup(buf, len, GFP_ATOMIC);
if (!mgmt_tx->buff) {
kfree(mgmt_tx);
return -ENOMEM;
@@ -154,7 +154,6 @@ static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len)
mgmt_tx->size = len;
- memcpy(mgmt_tx->buff, buf, len);
wilc_wlan_txq_add_mgmt_pkt(dev, mgmt_tx, mgmt_tx->buff, mgmt_tx->size,
mgmt_tx_complete);
--
2.10.0.GIT
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] staging: wilc1000: use kmemdup instead of kmalloc and memcpy
@ 2018-03-13 6:20 ` hariprasath.elango
0 siblings, 0 replies; 6+ messages in thread
From: hariprasath.elango @ 2018-03-13 6:20 UTC (permalink / raw)
To: aditya.shankar
Cc: devel, vbabu3, Greg Kroah-Hartman, linux-wireless, linux-kernel,
hariprasath.elango, Ganesh Krishna
From: HariPrasath Elango <hariprasath.elango@gmail.com>
Kmalloc followed by memcpy can be replaced by kmemdup.
Signed-off-by: HariPrasath Elango <hariprasath.elango@gmail.com>
---
drivers/staging/wilc1000/linux_mon.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/staging/wilc1000/linux_mon.c b/drivers/staging/wilc1000/linux_mon.c
index f93f411..c6fd6b3 100644
--- a/drivers/staging/wilc1000/linux_mon.c
+++ b/drivers/staging/wilc1000/linux_mon.c
@@ -146,7 +146,7 @@ static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len)
if (!mgmt_tx)
return -ENOMEM;
- mgmt_tx->buff = kmalloc(len, GFP_ATOMIC);
+ mgmt_tx->buff = kmemdup(buf, len, GFP_ATOMIC);
if (!mgmt_tx->buff) {
kfree(mgmt_tx);
return -ENOMEM;
@@ -154,7 +154,6 @@ static int mon_mgmt_tx(struct net_device *dev, const u8 *buf, size_t len)
mgmt_tx->size = len;
- memcpy(mgmt_tx->buff, buf, len);
wilc_wlan_txq_add_mgmt_pkt(dev, mgmt_tx, mgmt_tx->buff, mgmt_tx->size,
mgmt_tx_complete);
--
2.10.0.GIT
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] staging: wilc1000: use kmemdup instead of kmalloc and memcpy
2018-03-13 6:20 ` hariprasath.elango
@ 2018-03-13 7:43 ` Ajay Singh
-1 siblings, 0 replies; 6+ messages in thread
From: Ajay Singh @ 2018-03-13 7:43 UTC (permalink / raw)
To: hariprasath.elango, linux-kernel
Cc: aditya.shankar, vbabu3, Ganesh Krishna, Greg Kroah-Hartman,
linux-wireless, devel
On Tue, 13 Mar 2018 11:50:48 +0530
<hariprasath.elango@gmail.com> wrote:
> From: HariPrasath Elango <hariprasath.elango@gmail.com>
>
> Kmalloc followed by memcpy can be replaced by kmemdup.
>
> Signed-off-by: HariPrasath Elango <hariprasath.elango@gmail.com>
Reviewed-by: Ajay Singh <ajay.kathat@microchip.com>
Regards,
Ajay
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] staging: wilc1000: use kmemdup instead of kmalloc and memcpy
@ 2018-03-13 7:43 ` Ajay Singh
0 siblings, 0 replies; 6+ messages in thread
From: Ajay Singh @ 2018-03-13 7:43 UTC (permalink / raw)
To: hariprasath.elango, linux-kernel
Cc: devel, vbabu3, Greg Kroah-Hartman, linux-wireless,
Ganesh Krishna, aditya.shankar
On Tue, 13 Mar 2018 11:50:48 +0530
<hariprasath.elango@gmail.com> wrote:
> From: HariPrasath Elango <hariprasath.elango@gmail.com>
>
> Kmalloc followed by memcpy can be replaced by kmemdup.
>
> Signed-off-by: HariPrasath Elango <hariprasath.elango@gmail.com>
Reviewed-by: Ajay Singh <ajay.kathat@microchip.com>
Regards,
Ajay
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] Staging: wilc1000: Use kmemdup instead of kmalloc and memcpy
@ 2015-10-16 5:17 Shraddha Barke
0 siblings, 0 replies; 6+ messages in thread
From: Shraddha Barke @ 2015-10-16 5:17 UTC (permalink / raw)
To: outreachy-kernel
Replace kmalloc followed by memcpy with kmemdup
Problem found using coccicheck
Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
---
drivers/staging/wilc1000/host_interface.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
index 04f3bc2..e58b0a7 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -1793,16 +1793,15 @@ static int Handle_Key(struct host_if_drv *hif_drv,
strWIDList[2].val = (s8 *)(&(pstrHostIFkeyAttr->attr.wep.index));
strWIDList[2].size = sizeof(char);
- pu8keybuf = kmalloc(pstrHostIFkeyAttr->attr.wep.key_len, GFP_KERNEL);
+ pu8keybuf = kmemdup(pstrHostIFkeyAttr->attr.wep.key,
+ pstrHostIFkeyAttr->attr.wep.key_len,
+ GFP_KERNEL);
if (pu8keybuf == NULL) {
PRINT_ER("No buffer to send Key\n");
return -1;
}
- memcpy(pu8keybuf, pstrHostIFkeyAttr->attr.wep.key,
- pstrHostIFkeyAttr->attr.wep.key_len);
-
kfree(pstrHostIFkeyAttr->attr.wep.key);
strWIDList[3].id = (u16)WID_WEP_KEY_VALUE;
@@ -4633,21 +4632,20 @@ s32 host_int_add_beacon(struct host_if_drv *hif_drv, u32 u32Interval,
pstrSetBeaconParam->interval = u32Interval;
pstrSetBeaconParam->dtim_period = u32DTIMPeriod;
pstrSetBeaconParam->head_len = u32HeadLen;
- pstrSetBeaconParam->head = kmalloc(u32HeadLen, GFP_KERNEL);
+ pstrSetBeaconParam->head = kmemdup(pu8Head, u32HeadLen, GFP_KERNEL);
if (pstrSetBeaconParam->head == NULL) {
s32Error = -ENOMEM;
goto ERRORHANDLER;
}
- memcpy(pstrSetBeaconParam->head, pu8Head, u32HeadLen);
pstrSetBeaconParam->tail_len = u32TailLen;
if (u32TailLen > 0) {
- pstrSetBeaconParam->tail = kmalloc(u32TailLen, GFP_KERNEL);
+ pstrSetBeaconParam->tail = kmemdup(pu8Tail, u32TailLen,
+ GFP_KERNEL);
if (pstrSetBeaconParam->tail == NULL) {
s32Error = -ENOMEM;
goto ERRORHANDLER;
}
- memcpy(pstrSetBeaconParam->tail, pu8Tail, u32TailLen);
} else {
pstrSetBeaconParam->tail = NULL;
}
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH] Staging: wilc1000: Use kmemdup instead of kmalloc and memcpy
@ 2015-10-13 15:47 Shraddha Barke
0 siblings, 0 replies; 6+ messages in thread
From: Shraddha Barke @ 2015-10-13 15:47 UTC (permalink / raw)
To: outreachy-kernel
Replace kmalloc and memcpy with kmemdup.
Problem found using coccicheck
Signed-off-by: Shraddha Barke <shraddha.6596@gmail.com>
---
drivers/staging/wilc1000/host_interface.c | 14 ++++++--------
1 file changed, 6 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c
index ec04aec..9bc221c 100644
--- a/drivers/staging/wilc1000/host_interface.c
+++ b/drivers/staging/wilc1000/host_interface.c
@@ -2367,7 +2367,9 @@ static int Handle_Key(struct host_if_drv *hif_drv,
strWIDList[2].size = sizeof(char);
- pu8keybuf = kmalloc(pstrHostIFkeyAttr->uniHostIFkeyAttr.wep.key_len, GFP_KERNEL);
+ pu8keybuf = kmemdup(pstrHostIFkeyAttr->uniHostIFkeyAttr.wep.key,
+ pstrHostIFkeyAttr->uniHostIFkeyAttr.wep.key_len,
+ GFP_KERNEL);
if (pu8keybuf == NULL) {
@@ -2375,9 +2377,6 @@ static int Handle_Key(struct host_if_drv *hif_drv,
return -1;
}
- memcpy(pu8keybuf, pstrHostIFkeyAttr->uniHostIFkeyAttr.wep.key,
- pstrHostIFkeyAttr->uniHostIFkeyAttr.wep.key_len);
-
kfree(pstrHostIFkeyAttr->uniHostIFkeyAttr.wep.key);
@@ -6226,21 +6225,20 @@ s32 host_int_add_beacon(struct host_if_drv *hif_drv, u32 u32Interval,
pstrSetBeaconParam->u32Interval = u32Interval;
pstrSetBeaconParam->u32DTIMPeriod = u32DTIMPeriod;
pstrSetBeaconParam->u32HeadLen = u32HeadLen;
- pstrSetBeaconParam->pu8Head = kmalloc(u32HeadLen, GFP_KERNEL);
+ pstrSetBeaconParam->pu8Head = kmemdup(pu8Head, u32HeadLen, GFP_KERNEL);
if (pstrSetBeaconParam->pu8Head == NULL) {
s32Error = -ENOMEM;
goto ERRORHANDLER;
}
- memcpy(pstrSetBeaconParam->pu8Head, pu8Head, u32HeadLen);
pstrSetBeaconParam->u32TailLen = u32TailLen;
if (u32TailLen > 0) {
- pstrSetBeaconParam->pu8Tail = kmalloc(u32TailLen, GFP_KERNEL);
+ pstrSetBeaconParam->pu8Tail = kmemdup(pu8Tail, u32TailLen,
+ GFP_KERNEL);
if (pstrSetBeaconParam->pu8Tail == NULL) {
s32Error = -ENOMEM;
goto ERRORHANDLER;
}
- memcpy(pstrSetBeaconParam->pu8Tail, pu8Tail, u32TailLen);
} else {
pstrSetBeaconParam->pu8Tail = NULL;
}
--
2.1.4
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2018-03-13 7:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-13 6:20 [PATCH] staging: wilc1000: use kmemdup instead of kmalloc and memcpy hariprasath.elango
2018-03-13 6:20 ` hariprasath.elango
2018-03-13 7:43 ` Ajay Singh
2018-03-13 7:43 ` Ajay Singh
-- strict thread matches above, loose matches on Subject: below --
2015-10-16 5:17 [PATCH] Staging: wilc1000: Use " Shraddha Barke
2015-10-13 15:47 Shraddha Barke
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.