diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2017-05-13 18:31:26 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2017-06-30 02:04:10 -0400 |
commit | 30e7e3ecf39e578ffab6d5944c79c1d30dee0d3f (patch) | |
tree | b0512d1fbf39e90a795d0f066fe550464353d824 /net/core | |
parent | a2c841d94209f5775d354b563f4dccd76b876dc0 (diff) | |
download | linux-stable-30e7e3ecf39e578ffab6d5944c79c1d30dee0d3f.tar.gz linux-stable-30e7e3ecf39e578ffab6d5944c79c1d30dee0d3f.tar.bz2 linux-stable-30e7e3ecf39e578ffab6d5944c79c1d30dee0d3f.zip |
ethtool: don't open-code memdup_user()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'net/core')
-rw-r--r-- | net/core/ethtool.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/net/core/ethtool.c b/net/core/ethtool.c index 03111a2d6653..674b6c9cec18 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c @@ -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; } |