wlan-ng: replace calls to kmalloc and memcpy with kmemdup
authorXenia Ragiadakou <burzalodowa@gmail.com>
Mon, 13 May 2013 02:07:15 +0000 (05:07 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 13 May 2013 21:01:26 +0000 (14:01 -0700)
This patch replaces calls to kmalloc that are followed
by memcpy with calls to kmemdup.
This patch was found using coccicheck with api/memdup.cocci,
with memdup.cocci script slightly altered in the following way:

@depends on patch@
expression from,to,size,flag;
position p != {r1.p,r2.p};
@@

-  to = \(kmalloc@p\|kzalloc@p\)(size,flag);
+  to = kmemdup(from,size,flag);
-  memcpy(to, from, size);

Signed-off-by: Xenia Ragiadakou <burzalodowa@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/wlan-ng/prism2sta.c

index 428a9be2501069800ce960c882374206e3ff25d4..76374b2202285b201981fd6c618c7fc744e72ff0 100644 (file)
@@ -1122,8 +1122,7 @@ static void prism2sta_inf_hostscanresults(wlandevice_t *wlandev,
 
        kfree(hw->scanresults);
 
-       hw->scanresults = kmalloc(sizeof(hfa384x_InfFrame_t), GFP_ATOMIC);
-       memcpy(hw->scanresults, inf, sizeof(hfa384x_InfFrame_t));
+       hw->scanresults = kmemdup(inf, sizeof(hfa384x_InfFrame_t), GFP_ATOMIC);
 
        if (nbss == 0)
                nbss = -1;