lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Wed,  3 Jul 2013 10:59:22 +0200
From:	Alexandre Belloni <alexandre.belloni@...e-electrons.com>
To:	Wolfram Sang <wsa@...-dreams.de>
Cc:	linux-i2c@...r.kernel.org, linux-kernel@...r.kernel.org,
	marex@...x.de,
	Alexandre Belloni <alexandre.belloni@...e-electrons.com>
Subject: [PATCH] i2c: mxs: Better error handling

This patch fixes two error handling cases in mxs_i2c_xfer_msg():

 - in PIO mode, mxs_i2c_pio_setup_xfer() may return an error but i2c->cmd_err
 will not be set so mxs_i2c_xfer_msg() fails silently.

 - in DMA mode, mxs_i2c_dma_setup_xfer() may return an error and have
 i2c->cmd_err set to -ENXIO. In that case, we want to go through the
 MXS_I2C_CTRL1_CLR_GOT_A_NAK before returning.

Signed-off-by: Alexandre Belloni <alexandre.belloni@...e-electrons.com>
---
 drivers/i2c/busses/i2c-mxs.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/busses/i2c-mxs.c b/drivers/i2c/busses/i2c-mxs.c
index 2039f23..92f22b0 100644
--- a/drivers/i2c/busses/i2c-mxs.c
+++ b/drivers/i2c/busses/i2c-mxs.c
@@ -502,7 +502,7 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg,
 		INIT_COMPLETION(i2c->cmd_complete);
 		ret = mxs_i2c_dma_setup_xfer(adap, msg, flags);
 		if (ret)
-			return ret;
+			goto exit;
 
 		ret = wait_for_completion_timeout(&i2c->cmd_complete,
 						msecs_to_jiffies(1000));
@@ -510,6 +510,7 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg,
 			goto timeout;
 	}
 
+exit:
 	if (i2c->cmd_err == -ENXIO) {
 		/*
 		 * If the transfer fails with a NAK from the slave the
@@ -519,7 +520,8 @@ static int mxs_i2c_xfer_msg(struct i2c_adapter *adap, struct i2c_msg *msg,
 		       i2c->regs + MXS_I2C_CTRL1_SET);
 	}
 
-	ret = i2c->cmd_err;
+	if (i2c->cmd_err)
+		ret = i2c->cmd_err;
 
 	dev_dbg(i2c->dev, "Done with err=%d\n", ret);
 
-- 
1.8.1.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ