atmel: use memdup_user to simplify the code

use existing memdup_user() helper function instead of open-coding

Signed-off-by: YueHaibing <yuehaibing@huawei.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
This commit is contained in:
YueHaibing 2018-06-04 18:32:10 +08:00 committed by Kalle Valo
parent 2d1e9be001
commit 8668f9a57c

View File

@ -2646,14 +2646,9 @@ static int atmel_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
break;
}
if (!(new_firmware = kmalloc(com.len, GFP_KERNEL))) {
rc = -ENOMEM;
break;
}
if (copy_from_user(new_firmware, com.data, com.len)) {
kfree(new_firmware);
rc = -EFAULT;
new_firmware = memdup_user(com.data, com.len);
if (IS_ERR(new_firmware)) {
rc = PTR_ERR(new_firmware);
break;
}