* [PATCH] net: Use kmemdup rather than duplicating its implementation
@ 2011-11-17 22:43 Thomas Meyer
2011-11-18 15:48 ` Ben Hutchings
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Thomas Meyer @ 2011-11-17 22:43 UTC (permalink / raw)
To: samuel, davem, netdev, linux-kernel
The semantic patch that makes this change is available
in scripts/coccinelle/api/memdup.cocci.
Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---
diff -u -p a/net/irda/irttp.c b/net/irda/irttp.c
--- a/net/irda/irttp.c 2011-11-07 19:39:06.071138486 +0100
+++ b/net/irda/irttp.c 2011-11-08 10:59:07.152748948 +0100
@@ -1461,14 +1461,13 @@ struct tsap_cb *irttp_dup(struct tsap_cb
}
/* Allocate a new instance */
- new = kmalloc(sizeof(struct tsap_cb), GFP_ATOMIC);
+ new = kmemdup(orig, sizeof(struct tsap_cb), GFP_ATOMIC);
if (!new) {
IRDA_DEBUG(0, "%s(), unable to kmalloc\n", __func__);
spin_unlock_irqrestore(&irttp->tsaps->hb_spinlock, flags);
return NULL;
}
/* Dup */
- memcpy(new, orig, sizeof(struct tsap_cb));
spin_lock_init(&new->lock);
/* We don't need the old instance any more */
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: Use kmemdup rather than duplicating its implementation
2011-11-17 22:43 [PATCH] net: Use kmemdup rather than duplicating its implementation Thomas Meyer
@ 2011-11-18 15:48 ` Ben Hutchings
2011-11-18 17:32 ` Jesse Brandeburg
2011-11-21 20:03 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Ben Hutchings @ 2011-11-18 15:48 UTC (permalink / raw)
To: Thomas Meyer; +Cc: samuel, davem, netdev, linux-kernel
On Thu, 2011-11-17 at 23:43 +0100, Thomas Meyer wrote:
> The semantic patch that makes this change is available
> in scripts/coccinelle/api/memdup.cocci.
>
> Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
> ---
Similarly this is for the specific driver 'irttp' and not generally
'net'.
Ben.
> diff -u -p a/net/irda/irttp.c b/net/irda/irttp.c
> --- a/net/irda/irttp.c 2011-11-07 19:39:06.071138486 +0100
> +++ b/net/irda/irttp.c 2011-11-08 10:59:07.152748948 +0100
> @@ -1461,14 +1461,13 @@ struct tsap_cb *irttp_dup(struct tsap_cb
> }
>
> /* Allocate a new instance */
> - new = kmalloc(sizeof(struct tsap_cb), GFP_ATOMIC);
> + new = kmemdup(orig, sizeof(struct tsap_cb), GFP_ATOMIC);
> if (!new) {
> IRDA_DEBUG(0, "%s(), unable to kmalloc\n", __func__);
> spin_unlock_irqrestore(&irttp->tsaps->hb_spinlock, flags);
> return NULL;
> }
> /* Dup */
> - memcpy(new, orig, sizeof(struct tsap_cb));
> spin_lock_init(&new->lock);
>
> /* We don't need the old instance any more */
--
Ben Hutchings, Staff Engineer, Solarflare
Not speaking for my employer; that's the marketing department's job.
They asked us to note that Solarflare product names are trademarked.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: Use kmemdup rather than duplicating its implementation
2011-11-17 22:43 [PATCH] net: Use kmemdup rather than duplicating its implementation Thomas Meyer
2011-11-18 15:48 ` Ben Hutchings
@ 2011-11-18 17:32 ` Jesse Brandeburg
2011-11-21 20:03 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: Jesse Brandeburg @ 2011-11-18 17:32 UTC (permalink / raw)
To: Thomas Meyer; +Cc: samuel, davem, netdev, linux-kernel
On Thu, 17 Nov 2011 14:43:40 -0800
Thomas Meyer <thomas@m3y3r.de> wrote:
> The semantic patch that makes this change is available
> in scripts/coccinelle/api/memdup.cocci.
>
> Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
> ---
>
> diff -u -p a/net/irda/irttp.c b/net/irda/irttp.c
> --- a/net/irda/irttp.c 2011-11-07 19:39:06.071138486 +0100
> +++ b/net/irda/irttp.c 2011-11-08 10:59:07.152748948 +0100
> @@ -1461,14 +1461,13 @@ struct tsap_cb *irttp_dup(struct tsap_cb
> }
>
> /* Allocate a new instance */
> - new = kmalloc(sizeof(struct tsap_cb), GFP_ATOMIC);
> + new = kmemdup(orig, sizeof(struct tsap_cb), GFP_ATOMIC);
> if (!new) {
> IRDA_DEBUG(0, "%s(), unable to kmalloc\n", __func__);
> spin_unlock_irqrestore(&irttp->tsaps->hb_spinlock, flags);
> return NULL;
> }
> /* Dup */
this ^^^ comment should be removed also.
> - memcpy(new, orig, sizeof(struct tsap_cb));
> spin_lock_init(&new->lock);
>
> /* We don't need the old instance any more */
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net: Use kmemdup rather than duplicating its implementation
2011-11-17 22:43 [PATCH] net: Use kmemdup rather than duplicating its implementation Thomas Meyer
2011-11-18 15:48 ` Ben Hutchings
2011-11-18 17:32 ` Jesse Brandeburg
@ 2011-11-21 20:03 ` David Miller
2 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2011-11-21 20:03 UTC (permalink / raw)
To: thomas; +Cc: samuel, netdev, linux-kernel
From: Thomas Meyer <thomas@m3y3r.de>
Date: Thu, 17 Nov 2011 23:43:40 +0100
> The semantic patch that makes this change is available
> in scripts/coccinelle/api/memdup.cocci.
>
> Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
Applied, with subject line fixed and "Dup" comment removed.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-11-21 20:05 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-11-17 22:43 [PATCH] net: Use kmemdup rather than duplicating its implementation Thomas Meyer
2011-11-18 15:48 ` Ben Hutchings
2011-11-18 17:32 ` Jesse Brandeburg
2011-11-21 20:03 ` David Miller
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.