netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/18] Use kmemdup instead of kmalloc + memcpy
@ 2014-05-26 15:21 Benoit Taine
  2014-05-26 15:21 ` [PATCH 5/18] wcn36xx: " Benoit Taine
  2014-05-26 15:21 ` [PATCH 14/18] r8152: " Benoit Taine
  0 siblings, 2 replies; 4+ 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] 4+ 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
@ 2014-05-26 15:21 ` Benoit Taine
  2014-05-26 15:21 ` [PATCH 14/18] r8152: " Benoit Taine
  1 sibling, 0 replies; 4+ 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] 4+ 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
  2014-05-26 15:21 ` [PATCH 5/18] wcn36xx: " Benoit Taine
@ 2014-05-26 15:21 ` Benoit Taine
  2014-05-30 23:25   ` David Miller
  1 sibling, 1 reply; 4+ 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] 4+ 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; 4+ 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] 4+ messages in thread

end of thread, other threads:[~2014-05-30 23:25 UTC | newest]

Thread overview: 4+ 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 5/18] wcn36xx: " Benoit Taine
2014-05-26 15:21 ` [PATCH 14/18] r8152: " Benoit Taine
2014-05-30 23:25   ` David Miller

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).