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>
                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;