diff options
author | Heiner Kallweit <hkallweit1@gmail.com> | 2021-09-13 21:58:26 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2021-09-14 15:26:47 +0200 |
commit | b9bbc4c1debc837ba56872fb3b2499ba6459ca8b (patch) | |
tree | 51388f433d655fbd5996d4b2a550f305cd144300 /net/ethtool | |
parent | net: wwan: iosm: fix linux-next build error (diff) | |
download | linux-b9bbc4c1debc837ba56872fb3b2499ba6459ca8b.tar.xz linux-b9bbc4c1debc837ba56872fb3b2499ba6459ca8b.zip |
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: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/ethtool')
-rw-r--r-- | net/ethtool/ioctl.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/net/ethtool/ioctl.c b/net/ethtool/ioctl.c index f2abc3152888..999e2a6bed13 100644 --- a/net/ethtool/ioctl.c +++ b/net/ethtool/ioctl.c @@ -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; |