summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/atmel/atmel.c
diff options
context:
space:
mode:
authorYueHaibing <yuehaibing@huawei.com>2018-06-04 18:32:10 +0800
committerKalle Valo <kvalo@codeaurora.org>2018-06-27 19:06:00 +0300
commit8668f9a57c8c551f3e6a45d2733e64686c7b7904 (patch)
tree9f3c3497aa62b7b383200464aa9a0f04eeb6885a /drivers/net/wireless/atmel/atmel.c
parent2d1e9be0016230f3707812243561fbd16f1aea4b (diff)
downloadlwn-8668f9a57c8c551f3e6a45d2733e64686c7b7904.tar.gz
lwn-8668f9a57c8c551f3e6a45d2733e64686c7b7904.zip
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>
Diffstat (limited to 'drivers/net/wireless/atmel/atmel.c')
-rw-r--r--drivers/net/wireless/atmel/atmel.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/drivers/net/wireless/atmel/atmel.c b/drivers/net/wireless/atmel/atmel.c
index b01dc34d55af..0d8e0af3f74b 100644
--- a/drivers/net/wireless/atmel/atmel.c
+++ b/drivers/net/wireless/atmel/atmel.c
@@ -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;
}