[PATCH] i2c: at91: add a sanity check on i2c message length

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Ludovic Desroches <ludovic.desroches@xxxxxxxxx>

If the i2c message length is zero, i2c-at91 will directly return an error
instead of trying to send a zero-length message.

Signed-off-by: Ludovic Desroches <ludovic.desroches@xxxxxxxxx>
---

fix for 3.7

 drivers/i2c/busses/i2c-at91.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/i2c/busses/i2c-at91.c b/drivers/i2c/busses/i2c-at91.c
index aa59a25..eaddc77 100644
--- a/drivers/i2c/busses/i2c-at91.c
+++ b/drivers/i2c/busses/i2c-at91.c
@@ -263,6 +263,9 @@ static int at91_twi_xfer(struct i2c_adapter *adap, struct i2c_msg *msg, int num)
 	unsigned int_addr_flag = 0;
 	struct i2c_msg *m_start = msg;
 
+	if (!msg->len)
+		return -EINVAL;
+
 	dev_dbg(&adap->dev, "at91_xfer: processing %d messages:\n", num);
 
 	/*
-- 
1.7.11.3

--
To unsubscribe from this list: send the line "unsubscribe linux-i2c" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux