提交 b9bbc4c1 编写于 作者: H Heiner Kallweit 提交者: David S. Miller

ethtool: prevent endless loop if eeprom size is smaller than announced

It shouldn't happen, but can happen that readable eeprom size is smaller
than announced. Then we would be stuck in an endless loop here because
after reaching the actual end reads return eeprom.len = 0. I faced this
issue when making a mistake in driver development. Detect this scenario
and return an error.
Signed-off-by: NHeiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 0f440524
......@@ -1537,6 +1537,10 @@ static int ethtool_get_any_eeprom(struct net_device *dev, void __user *useraddr,
ret = getter(dev, &eeprom, data);
if (ret)
break;
if (!eeprom.len) {
ret = -EIO;
break;
}
if (copy_to_user(userbuf, data, eeprom.len)) {
ret = -EFAULT;
break;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册