[2.4] Fix possible memleaks in Ethtool ioctl handler
PATCH 1/1 [2.4] Fix possible memleaks in Ethtool ioctl handler
Hello!
There are trivial memleaks in Ethtool ioctl handler, while not all that dangerous since only root can cause them (I presume), still trivial patch below is needed at least for the correctness sake. Please apply.
Found with help of smatch.
===== net/core/ethtool.c 1.4 vs edited =====
net/core/ethtool.c +8 -4
@@ -247,8 +247,10 @@if (!data)return -ENOMEM ; -if (copy_from_user (data, useraddr +sizeof (eeprom), len)) -return -EFAULT ; +if (copy_from_user (data, useraddr +sizeof (eeprom), len)) { + ret = -EFAULT ; + goto out; + } ret = dev->ethtool_ops->get_eeprom (dev, &eeprom, data);if (!ret)
@@ -287,8 +289,10 @@if (!data)return -ENOMEM ; -if (copy_from_user (data, useraddr +sizeof (eeprom), len)) -return -EFAULT ; +if (copy_from_user (data, useraddr +sizeof (eeprom), len)) { + ret = -EFAULT ; + goto out; + } ret = dev->ethtool_ops->set_eeprom (dev, &eeprom, data);if (ret)