Skip to content

Commit

Permalink
irttp: Use kmemdup rather than duplicating its implementation
Browse files Browse the repository at this point in the history
The semantic patch that makes this change is available
in scripts/coccinelle/api/memdup.cocci.

Signed-off-by: Thomas Meyer <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
thomasmey authored and davem330 committed Nov 21, 2011
1 parent efd0bf9 commit 8524b00
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions net/irda/irttp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1461,14 +1461,12 @@ struct tsap_cb *irttp_dup(struct tsap_cb *orig, void *instance)
}

/* 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 */
Expand Down

0 comments on commit 8524b00

Please sign in to comment.