Commit 871ff2eb authored by Geliang Tang's avatar Geliang Tang Committed by David S. Miller

yam: use memdup_user

Use memdup_user() helper instead of open-coding to simplify the code.
Signed-off-by: default avatarGeliang Tang <geliangtang@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 294316a4
...@@ -976,12 +976,10 @@ static int yam_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) ...@@ -976,12 +976,10 @@ static int yam_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
case SIOCYAMSMCS: case SIOCYAMSMCS:
if (netif_running(dev)) if (netif_running(dev))
return -EINVAL; /* Cannot change this parameter when up */ return -EINVAL; /* Cannot change this parameter when up */
if ((ym = kmalloc(sizeof(struct yamdrv_ioctl_mcs), GFP_KERNEL)) == NULL) ym = memdup_user(ifr->ifr_data,
return -ENOBUFS; sizeof(struct yamdrv_ioctl_mcs));
if (copy_from_user(ym, ifr->ifr_data, sizeof(struct yamdrv_ioctl_mcs))) { if (IS_ERR(ym))
kfree(ym); return PTR_ERR(ym);
return -EFAULT;
}
if (ym->bitrate > YAM_MAXBITRATE) { if (ym->bitrate > YAM_MAXBITRATE) {
kfree(ym); kfree(ym);
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment