[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180604103210.23984-1-yuehaibing@huawei.com>
Date: Mon, 4 Jun 2018 18:32:10 +0800
From: YueHaibing <yuehaibing@...wei.com>
To: <davem@...emloft.net>, <kvalo@...eaurora.org>
CC: <netdev@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linux-wireless@...r.kernel.org>,
YueHaibing <yuehaibing@...wei.com>
Subject: [PATCH] atmel: use memdup_user to simplify the code
use existing memdup_user() helper function instead of open-coding
Signed-off-by: YueHaibing <yuehaibing@...wei.com>
---
drivers/net/wireless/atmel/atmel.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/net/wireless/atmel/atmel.c b/drivers/net/wireless/atmel/atmel.c
index d122386..30b479a 100644
--- a/drivers/net/wireless/atmel/atmel.c
+++ b/drivers/net/wireless/atmel/atmel.c
@@ -2657,14 +2657,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;
}
--
2.7.0
Powered by blists - more mailing lists