mirror of
https://github.com/FEX-Emu/linux.git
synced 2025-01-26 20:58:33 +00:00
yam: 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>
This commit is contained in:
parent
294316a4af
commit
871ff2ebe0
@ -976,12 +976,10 @@ static int yam_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
|
||||
case SIOCYAMSMCS:
|
||||
if (netif_running(dev))
|
||||
return -EINVAL; /* Cannot change this parameter when up */
|
||||
if ((ym = kmalloc(sizeof(struct yamdrv_ioctl_mcs), GFP_KERNEL)) == NULL)
|
||||
return -ENOBUFS;
|
||||
if (copy_from_user(ym, ifr->ifr_data, sizeof(struct yamdrv_ioctl_mcs))) {
|
||||
kfree(ym);
|
||||
return -EFAULT;
|
||||
}
|
||||
ym = memdup_user(ifr->ifr_data,
|
||||
sizeof(struct yamdrv_ioctl_mcs));
|
||||
if (IS_ERR(ym))
|
||||
return PTR_ERR(ym);
|
||||
if (ym->bitrate > YAM_MAXBITRATE) {
|
||||
kfree(ym);
|
||||
return -EINVAL;
|
||||
|
Loading…
x
Reference in New Issue
Block a user