diff options
author | Vasyl Gomonovych <gomonovych@gmail.com> | 2017-11-22 16:29:57 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-11-28 16:57:54 +0100 |
commit | f95d5bf03b5ec0d7ea8e552e15abe70c646249b5 (patch) | |
tree | d079a1d177f77e4f441764f2f1c78fd4ef58cfb9 /drivers/net | |
parent | bnxt_en: Fix an error handling path in 'bnxt_get_module_eeprom()' (diff) | |
download | linux-f95d5bf03b5ec0d7ea8e552e15abe70c646249b5.tar.xz linux-f95d5bf03b5ec0d7ea8e552e15abe70c646249b5.zip |
lmc: Use memdup_user() as a cleanup
Fix coccicheck warning which recommends to use memdup_user():
drivers/net/wan/lmc/lmc_main.c:497:27-34: WARNING opportunity for memdup_user
Generated by: scripts/coccinelle/memdup_user/memdup_user.cocci
Signed-off-by: Vasyl Gomonovych <gomonovych@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/wan/lmc/lmc_main.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c index 37b1e0d03e31..90a4ad9a2d08 100644 --- a/drivers/net/wan/lmc/lmc_main.c +++ b/drivers/net/wan/lmc/lmc_main.c @@ -494,18 +494,11 @@ int lmc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/ break; } - data = kmalloc(xc.len, GFP_KERNEL); - if (!data) { - ret = -ENOMEM; + data = memdup_user(xc.data, xc.len); + if (IS_ERR(data)) { + ret = PTR_ERR(data); break; } - - if(copy_from_user(data, xc.data, xc.len)) - { - kfree(data); - ret = -ENOMEM; - break; - } printk("%s: Starting load of data Len: %d at 0x%p == 0x%p\n", dev->name, xc.len, xc.data, data); |