diff options
author | Julia Lawall <julia@diku.dk> | 2010-05-15 17:16:03 -0400 |
---|---|---|
committer | John W. Linville <linville@tuxdriver.com> | 2010-06-02 16:13:10 -0400 |
commit | 02730029530e7ca2a4d413d6afa67bbc9548c8c2 (patch) | |
tree | 9237a49af89c9c892836eb8589432efe982f45be /drivers/net/wireless/libertas_tf/if_usb.c | |
parent | 80caf6017ace944035210ca2bba7abeb85eb0c5c (diff) |
drivers/net/wireless/libertas_tf: Use kmemdup
Use kmemdup when some other buffer is immediately copied into the
allocated region.
A simplified version of the semantic patch that makes this change is as
follows: (http://coccinelle.lip6.fr/)
// <smpl>
@@
expression from,to,size,flag;
statement S;
@@
- to = \(kmalloc\|kzalloc\)(size,flag);
+ to = kmemdup(from,size,flag);
if (to==NULL || ...) S
- memcpy(to, from, size);
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/libertas_tf/if_usb.c')
-rw-r--r-- | drivers/net/wireless/libertas_tf/if_usb.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/drivers/net/wireless/libertas_tf/if_usb.c b/drivers/net/wireless/libertas_tf/if_usb.c index c445500ffc6..b172f5d87a3 100644 --- a/drivers/net/wireless/libertas_tf/if_usb.c +++ b/drivers/net/wireless/libertas_tf/if_usb.c | |||
@@ -538,7 +538,8 @@ static void if_usb_receive_fwload(struct urb *urb) | |||
538 | return; | 538 | return; |
539 | } | 539 | } |
540 | 540 | ||
541 | syncfwheader = kmalloc(sizeof(struct fwsyncheader), GFP_ATOMIC); | 541 | syncfwheader = kmemdup(skb->data, sizeof(struct fwsyncheader), |
542 | GFP_ATOMIC); | ||
542 | if (!syncfwheader) { | 543 | if (!syncfwheader) { |
543 | lbtf_deb_usbd(&cardp->udev->dev, "Failure to allocate syncfwheader\n"); | 544 | lbtf_deb_usbd(&cardp->udev->dev, "Failure to allocate syncfwheader\n"); |
544 | kfree_skb(skb); | 545 | kfree_skb(skb); |
@@ -546,8 +547,6 @@ static void if_usb_receive_fwload(struct urb *urb) | |||
546 | return; | 547 | return; |
547 | } | 548 | } |
548 | 549 | ||
549 | memcpy(syncfwheader, skb->data, sizeof(struct fwsyncheader)); | ||
550 | |||
551 | if (!syncfwheader->cmd) { | 550 | if (!syncfwheader->cmd) { |
552 | lbtf_deb_usb2(&cardp->udev->dev, "FW received Blk with correct CRC\n"); | 551 | lbtf_deb_usb2(&cardp->udev->dev, "FW received Blk with correct CRC\n"); |
553 | lbtf_deb_usb2(&cardp->udev->dev, "FW received Blk seqnum = %d\n", | 552 | lbtf_deb_usb2(&cardp->udev->dev, "FW received Blk seqnum = %d\n", |