summaryrefslogtreecommitdiffstats
path: root/drivers/net/hippi
diff options
context:
space:
mode:
authorGeliang Tang <geliangtang@gmail.com>2017-05-06 23:42:16 +0800
committerDavid S. Miller <davem@davemloft.net>2017-05-08 15:02:09 -0400
commit294316a4af16cd5c355a80bd2dc7ea803b88f6ba (patch)
treeecc7fbc95caf37fe837d535615d97494353cdeb7 /drivers/net/hippi
parent3bb4858fda1cac2ae677edb5134932af4c7f8ff8 (diff)
downloadlinux-294316a4af16cd5c355a80bd2dc7ea803b88f6ba.tar.gz
linux-294316a4af16cd5c355a80bd2dc7ea803b88f6ba.tar.bz2
linux-294316a4af16cd5c355a80bd2dc7ea803b88f6ba.zip
net/hippi/rrunner: use memdup_user
Use memdup_user() helper instead of open-coding to simplify the code. Signed-off-by: Geliang Tang <geliangtang@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/hippi')
-rw-r--r--drivers/net/hippi/rrunner.c17
1 files changed, 7 insertions, 10 deletions
diff --git a/drivers/net/hippi/rrunner.c b/drivers/net/hippi/rrunner.c
index dd7fc6659ad4..365c4d987a01 100644
--- a/drivers/net/hippi/rrunner.c
+++ b/drivers/net/hippi/rrunner.c
@@ -1615,17 +1615,14 @@ static int rr_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
return -EPERM;
}
- image = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL);
- oldimage = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL);
- if (!image || !oldimage) {
- error = -ENOMEM;
- goto wf_out;
- }
+ image = memdup_user(rq->ifr_data, EEPROM_BYTES);
+ if (IS_ERR(image))
+ return PTR_ERR(image);
- error = copy_from_user(image, rq->ifr_data, EEPROM_BYTES);
- if (error) {
- error = -EFAULT;
- goto wf_out;
+ oldimage = kmalloc(EEPROM_BYTES, GFP_KERNEL);
+ if (!oldimage) {
+ kfree(image);
+ return -ENOMEM;
}
if (rrpriv->fw_running){