From: Rodrigo Alencar <[email protected]>

Verify that the expected number of i2c messages were transferred when
ad5686_i2c_read() is called. This issue exists since the support for I2C
devices where first introduced.

Fixes: 4177381b4401 ("iio:dac:ad5686: Add AD5671R/75R/94/94R/95R/96/96R 
support")
Reported-by: [email protected]
Closes: https://lore.kernel.org/all/[email protected]/
Signed-off-by: Rodrigo Alencar <[email protected]>
---
 drivers/iio/dac/ad5696-i2c.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/iio/dac/ad5696-i2c.c b/drivers/iio/dac/ad5696-i2c.c
index 279309329b64..6f726e6301a6 100644
--- a/drivers/iio/dac/ad5696-i2c.c
+++ b/drivers/iio/dac/ad5696-i2c.c
@@ -40,8 +40,8 @@ static int ad5686_i2c_read(struct ad5686_state *st, u8 addr)
                                      0x00);
 
        ret = i2c_transfer(i2c->adapter, msg, 2);
-       if (ret < 0)
-               return ret;
+       if (ret != 2)
+               return ret < 0 ? ret : -EIO;
 
        return be16_to_cpu(st->data[0].d16);
 }

-- 
2.43.0



Reply via email to