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:	Thu, 10 Oct 2013 10:39:38 +0200
From:	Ionut Nicu <ioan.nicu.ext@....com>
To:	Peter Korsgaard <peter.korsgaard@...co.com>
CC:	Wolfram Sang <wsa@...-dreams.de>,
	Alexander Sverdlin <alexander.sverdlin@....com>,
	linux-i2c@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH 2/2] i2c-mux-gpio: eliminate i2c channel order assumptions

The i2c-mux driver uses the chan_id parameter provided
in i2c_add_mux_adapter as a parameter to the select
and deselect callbacks while the i2c-mux-gpio driver
uses the chan_id as an index in the mux->data.values
array.

A simple example of where this doesn't work is when we
have a device tree like this:

i2cmux {
	i2c@1 {
		reg = <1>;
		...
	};

	i2c@0 {
		reg = <0>;
		...
	};
};

The mux->data.values array will be { 1, 0 }, but when
the i2-mux driver will try to select channel 0, the
i2c-mux-gpio driver will actually use values[0], hence 1
as the gpio selection value.

Signed-off-by: Ionut Nicu <ioan.nicu.ext@....com>
---
 drivers/i2c/muxes/i2c-mux-gpio.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c
index b5f17ef..3505d0e 100644
--- a/drivers/i2c/muxes/i2c-mux-gpio.c
+++ b/drivers/i2c/muxes/i2c-mux-gpio.c
@@ -43,7 +43,7 @@ static int i2c_mux_gpio_select(struct i2c_adapter *adap, void *data, u32 chan)
 {
 	struct gpiomux *mux = data;
 
-	i2c_mux_gpio_set(mux, mux->data.values[chan]);
+	i2c_mux_gpio_set(mux, chan);
 
 	return 0;
 }
@@ -233,7 +233,7 @@ static int i2c_mux_gpio_probe(struct platform_device *pdev)
 		unsigned int class = mux->data.classes ? mux->data.classes[i] : 0;
 
 		mux->adap[i] = i2c_add_mux_adapter(parent, &pdev->dev, mux, nr,
-						   i, class,
+						   mux->data.values[i], class,
 						   i2c_mux_gpio_select, deselect);
 		if (!mux->adap[i]) {
 			ret = -ENODEV;
-- 
1.7.1

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