mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-02 17:26:40 +07:00
ethtool: don't open-code memdup_user()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
a2c841d942
commit
30e7e3ecf3
@ -2322,16 +2322,12 @@ static int ethtool_set_tunable(struct net_device *dev, void __user *useraddr)
|
||||
ret = ethtool_tunable_valid(&tuna);
|
||||
if (ret)
|
||||
return ret;
|
||||
data = kmalloc(tuna.len, GFP_USER);
|
||||
if (!data)
|
||||
return -ENOMEM;
|
||||
useraddr += sizeof(tuna);
|
||||
ret = -EFAULT;
|
||||
if (copy_from_user(data, useraddr, tuna.len))
|
||||
goto out;
|
||||
data = memdup_user(useraddr, tuna.len);
|
||||
if (IS_ERR(data))
|
||||
return PTR_ERR(data);
|
||||
ret = ops->set_tunable(dev, &tuna, data);
|
||||
|
||||
out:
|
||||
kfree(data);
|
||||
return ret;
|
||||
}
|
||||
@ -2507,18 +2503,14 @@ static int set_phy_tunable(struct net_device *dev, void __user *useraddr)
|
||||
ret = ethtool_phy_tunable_valid(&tuna);
|
||||
if (ret)
|
||||
return ret;
|
||||
data = kmalloc(tuna.len, GFP_USER);
|
||||
if (!data)
|
||||
return -ENOMEM;
|
||||
useraddr += sizeof(tuna);
|
||||
ret = -EFAULT;
|
||||
if (copy_from_user(data, useraddr, tuna.len))
|
||||
goto out;
|
||||
data = memdup_user(useraddr, tuna.len);
|
||||
if (IS_ERR(data))
|
||||
return PTR_ERR(data);
|
||||
mutex_lock(&phydev->lock);
|
||||
ret = phydev->drv->set_tunable(phydev, &tuna, data);
|
||||
mutex_unlock(&phydev->lock);
|
||||
|
||||
out:
|
||||
kfree(data);
|
||||
return ret;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user