Commit 80ec82e3 authored by Austin Kim's avatar Austin Kim Committed by David S. Miller

net: ethtool: clear heap allocations for ethtool function

Several ethtool functions leave heap uncleared (potentially) by
drivers. This will leave the unused portion of heap unchanged and
might copy the full contents back to userspace.
Signed-off-by: default avatarAustin Kim <austindh.kim@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f2386cf7
...@@ -1421,7 +1421,7 @@ static int ethtool_get_any_eeprom(struct net_device *dev, void __user *useraddr, ...@@ -1421,7 +1421,7 @@ static int ethtool_get_any_eeprom(struct net_device *dev, void __user *useraddr,
if (eeprom.offset + eeprom.len > total_len) if (eeprom.offset + eeprom.len > total_len)
return -EINVAL; return -EINVAL;
data = kmalloc(PAGE_SIZE, GFP_USER); data = kzalloc(PAGE_SIZE, GFP_USER);
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
...@@ -1486,7 +1486,7 @@ static int ethtool_set_eeprom(struct net_device *dev, void __user *useraddr) ...@@ -1486,7 +1486,7 @@ static int ethtool_set_eeprom(struct net_device *dev, void __user *useraddr)
if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev)) if (eeprom.offset + eeprom.len > ops->get_eeprom_len(dev))
return -EINVAL; return -EINVAL;
data = kmalloc(PAGE_SIZE, GFP_USER); data = kzalloc(PAGE_SIZE, GFP_USER);
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
...@@ -1765,7 +1765,7 @@ static int ethtool_self_test(struct net_device *dev, char __user *useraddr) ...@@ -1765,7 +1765,7 @@ static int ethtool_self_test(struct net_device *dev, char __user *useraddr)
return -EFAULT; return -EFAULT;
test.len = test_len; test.len = test_len;
data = kmalloc_array(test_len, sizeof(u64), GFP_USER); data = kcalloc(test_len, sizeof(u64), GFP_USER);
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
...@@ -2293,7 +2293,7 @@ static int ethtool_get_tunable(struct net_device *dev, void __user *useraddr) ...@@ -2293,7 +2293,7 @@ static int ethtool_get_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); data = kzalloc(tuna.len, GFP_USER);
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
ret = ops->get_tunable(dev, &tuna, data); ret = ops->get_tunable(dev, &tuna, data);
...@@ -2485,7 +2485,7 @@ static int get_phy_tunable(struct net_device *dev, void __user *useraddr) ...@@ -2485,7 +2485,7 @@ static int get_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); data = kzalloc(tuna.len, GFP_USER);
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
if (phy_drv_tunable) { if (phy_drv_tunable) {
......
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