mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-06 19:07:52 +00:00
Staging: rtl8712: Use memdup_user() instead of copy_from_user()
Use memdup_user() to avoid its duplicated implementation and simplify code. memdup_user() uses GFP_KERNEL instead of GFP_ATOMIC, which is valid because copy_from_user() might sleep and it's useless to make the allocation atomic. Found with coccinelle. Signed-off-by: Cristina Opriceana <cristina.opriceana@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
66687e6aed
commit
45de432775
1 changed files with 3 additions and 7 deletions
|
@ -1912,13 +1912,9 @@ static int r871x_mp_ioctl_hdl(struct net_device *dev,
|
||||||
bset = (u8)(p->flags & 0xFFFF);
|
bset = (u8)(p->flags & 0xFFFF);
|
||||||
len = p->length;
|
len = p->length;
|
||||||
pparmbuf = NULL;
|
pparmbuf = NULL;
|
||||||
pparmbuf = kmalloc(len, GFP_ATOMIC);
|
pparmbuf = memdup_user(p->pointer, len);
|
||||||
if (pparmbuf == NULL) {
|
if (IS_ERR(pparmbuf)) {
|
||||||
ret = -ENOMEM;
|
ret = PTR_ERR(pparmbuf);
|
||||||
goto _r871x_mp_ioctl_hdl_exit;
|
|
||||||
}
|
|
||||||
if (copy_from_user(pparmbuf, p->pointer, len)) {
|
|
||||||
ret = -EFAULT;
|
|
||||||
goto _r871x_mp_ioctl_hdl_exit;
|
goto _r871x_mp_ioctl_hdl_exit;
|
||||||
}
|
}
|
||||||
poidparam = (struct mp_ioctl_param *)pparmbuf;
|
poidparam = (struct mp_ioctl_param *)pparmbuf;
|
||||||
|
|
Loading…
Reference in a new issue