Skip to contentSkip to conversation

staging: wilc1000: use kmemdup instead of kmalloc and memcpy

PATCH In review [email protected] 2 participants 2 messages Mar 13, 2018 Staging

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 staging: wilc1000: use kmemdup instead of kmalloc and memcpy

From: HariPrasath Elango <[email protected]>

Kmalloc followed by memcpy can be replaced by kmemdup.

---
 drivers/staging/wilc1000/linux_mon.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/staging/wilc1000/linux_mon.c +1 -2
index f93f411..c6fd6b3 100644
@@ -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);
 
Signature · 6 lines
2.10.0.GIT

_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · On Tue, 13 Mar 2018 11:50:48 +0530 <[email protected]> wrote:

From: HariPrasath Elango <[email protected]>

Kmalloc followed by memcpy can be replaced by kmemdup.

Regards,
Ajay
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel