Commit 30e7e3ec authored by Al Viro's avatar Al Viro

ethtool: don't open-code memdup_user()

Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
parent a2c841d9
...@@ -2322,16 +2322,12 @@ static int ethtool_set_tunable(struct net_device *dev, void __user *useraddr) ...@@ -2322,16 +2322,12 @@ static int ethtool_set_tunable(struct net_device *dev, void __user *useraddr)
ret = ethtool_tunable_valid(&tuna); ret = ethtool_tunable_valid(&tuna);
if (ret) if (ret)
return ret; return ret;
data = kmalloc(tuna.len, GFP_USER);
if (!data)
return -ENOMEM;
useraddr += sizeof(tuna); useraddr += sizeof(tuna);
ret = -EFAULT; data = memdup_user(useraddr, tuna.len);
if (copy_from_user(data, useraddr, tuna.len)) if (IS_ERR(data))
goto out; return PTR_ERR(data);
ret = ops->set_tunable(dev, &tuna, data); ret = ops->set_tunable(dev, &tuna, data);
out:
kfree(data); kfree(data);
return ret; return ret;
} }
...@@ -2507,18 +2503,14 @@ static int set_phy_tunable(struct net_device *dev, void __user *useraddr) ...@@ -2507,18 +2503,14 @@ static int set_phy_tunable(struct net_device *dev, void __user *useraddr)
ret = ethtool_phy_tunable_valid(&tuna); ret = ethtool_phy_tunable_valid(&tuna);
if (ret) if (ret)
return ret; return ret;
data = kmalloc(tuna.len, GFP_USER);
if (!data)
return -ENOMEM;
useraddr += sizeof(tuna); useraddr += sizeof(tuna);
ret = -EFAULT; data = memdup_user(useraddr, tuna.len);
if (copy_from_user(data, useraddr, tuna.len)) if (IS_ERR(data))
goto out; return PTR_ERR(data);
mutex_lock(&phydev->lock); mutex_lock(&phydev->lock);
ret = phydev->drv->set_tunable(phydev, &tuna, data); ret = phydev->drv->set_tunable(phydev, &tuna, data);
mutex_unlock(&phydev->lock); mutex_unlock(&phydev->lock);
out:
kfree(data); kfree(data);
return ret; return ret;
} }
......
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