mirror of https://gitee.com/openkylin/linux.git
Staging: wilc1000: cfg80211: Use kmemdup instead of kmalloc and memcpy
Replace calls to kmalloc followed by a memcpy with a direct call to kmemdup. The Coccinelle semantic patch used to make this change is as follows: @@ 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); Signed-off-by: Shreeya Patel <shreeya.patel23498@gmail.com> Reviewed-by: Stefano Brivio <sbrivio@redhat.com> Link: https://lore.kernel.org/r/20200313112451.25610-1-shreeya.patel23498@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
76498b49f5
commit
d9e709d017
|
@ -1142,14 +1142,13 @@ static int mgmt_tx(struct wiphy *wiphy,
|
|||
goto out;
|
||||
}
|
||||
|
||||
mgmt_tx->buff = kmalloc(len, GFP_KERNEL);
|
||||
mgmt_tx->buff = kmemdup(buf, len, GFP_KERNEL);
|
||||
if (!mgmt_tx->buff) {
|
||||
ret = -ENOMEM;
|
||||
kfree(mgmt_tx);
|
||||
goto out;
|
||||
}
|
||||
|
||||
memcpy(mgmt_tx->buff, buf, len);
|
||||
mgmt_tx->size = len;
|
||||
|
||||
if (ieee80211_is_probe_resp(mgmt->frame_control)) {
|
||||
|
|
Loading…
Reference in New Issue