[PATCH] i2c: lpi2c: fix potential read of uninitialized variable

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

 



If the continue statement in the do {} while () loop is
reached on the first iteration, the loop condition is evaluated without
having first being set.

Fix this by initializing it to the maximum length of the I2C message.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 drivers/i2c/busses/i2c-imx-lpi2c.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-imx-lpi2c.c b/drivers/i2c/busses/i2c-imx-lpi2c.c
index e32bc4fd1805..763074ae63c7 100644
--- a/drivers/i2c/busses/i2c-imx-lpi2c.c
+++ b/drivers/i2c/busses/i2c-imx-lpi2c.c
@@ -330,7 +330,7 @@ static void lpi2c_imx_set_rx_watermark(struct lpi2c_imx_struct *lpi2c_imx)
 
 static int lpi2c_imx_write_txfifo(struct lpi2c_imx_struct *lpi2c_imx)
 {
-	unsigned int data, remaining;
+	unsigned int data, remaining = lpi2c_imx->msglen;
 	unsigned int timeout = 100000;;
 
 	do {
@@ -353,7 +353,7 @@ static int lpi2c_imx_write_txfifo(struct lpi2c_imx_struct *lpi2c_imx)
 
 static int lpi2c_imx_read_rxfifo(struct lpi2c_imx_struct *lpi2c_imx)
 {
-	unsigned int remaining;
+	unsigned int remaining = lpi2c_imx->msglen;
 	unsigned int data;
 	unsigned int timeout = 100000;;
 
-- 
2.39.5





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux