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>
This commit is contained in:
Vasyl Gomonovych 2017-11-22 16:29:57 +01:00 committed by David S. Miller
parent dea521a2b9
commit f95d5bf03b
1 changed files with 3 additions and 10 deletions

View File

@ -494,19 +494,12 @@ int lmc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) /*fold00*/
break; break;
} }
data = kmalloc(xc.len, GFP_KERNEL); data = memdup_user(xc.data, xc.len);
if (!data) { if (IS_ERR(data)) {
ret = -ENOMEM; ret = PTR_ERR(data);
break; 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); printk("%s: Starting load of data Len: %d at 0x%p == 0x%p\n", dev->name, xc.len, xc.data, data);
spin_lock_irqsave(&sc->lmc_lock, flags); spin_lock_irqsave(&sc->lmc_lock, flags);