diff options
author | Julia Lawall | 2010-05-15 23:21:43 +0200 |
---|---|---|
committer | Greg Kroah-Hartman | 2010-05-18 01:31:15 +0200 |
commit | 94002c07ff0e207a883519ccc35c0b5390b29331 (patch) | |
tree | b730a75ef2ad76d1e3a322e5982b30ca46b6c487 /drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | |
parent | Staging: vt6655: use ETH_HLEN macro instead of custom one (diff) | |
download | kernel-qcow2-linux-94002c07ff0e207a883519ccc35c0b5390b29331.tar.gz kernel-qcow2-linux-94002c07ff0e207a883519ccc35c0b5390b29331.tar.xz kernel-qcow2-linux-94002c07ff0e207a883519ccc35c0b5390b29331.zip |
Staging: 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: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c')
-rw-r--r-- | drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c index a6955e2b45c4..a2e84c578579 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_softmac.c @@ -1579,10 +1579,9 @@ static inline u16 auth_parse(struct sk_buff *skb, u8** challenge, int *chlen) if(*(t++) == MFIE_TYPE_CHALLENGE){ *chlen = *(t++); - *challenge = kmalloc(*chlen, GFP_ATOMIC); + *challenge = kmemdup(t, *chlen, GFP_ATOMIC); if (!*challenge) return -ENOMEM; - memcpy(*challenge, t, *chlen); } } @@ -2870,11 +2869,11 @@ static int ieee80211_wpa_set_wpa_ie(struct ieee80211_device *ieee, return -EINVAL; if (param->u.wpa_ie.len) { - buf = kmalloc(param->u.wpa_ie.len, GFP_KERNEL); + buf = kmemdup(param->u.wpa_ie.data, param->u.wpa_ie.len, + GFP_KERNEL); if (buf == NULL) return -ENOMEM; - memcpy(buf, param->u.wpa_ie.data, param->u.wpa_ie.len); kfree(ieee->wpa_ie); ieee->wpa_ie = buf; ieee->wpa_ie_len = param->u.wpa_ie.len; |