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 for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20190614214748.2389-1-fancer.lancer@gmail.com>
Date:   Sat, 15 Jun 2019 00:47:49 +0300
From:   Serge Semin <fancer.lancer@...il.com>
To:     Jean Delvare <jdelvare@...e.com>,
        Peter Korsgaard <peter.korsgaard@...co.com>,
        Peter Rosin <peda@...ntia.se>
Cc:     Serge Semin <Sergey.Semin@...latforms.ru>,
        Mika Westerberg <mika.westerberg@...ux.intel.com>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Linus Walleij <linus.walleij@...aro.org>,
        linux-i2c@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] i2c: mux-gpio: Use "mux" con_id to find channel GPIOs

Recent patch - ("i2c: mux/i801: Switch to use descriptor passing")
altered the i2c-mux-gpio driver to use the GPIO-descriptor
based interface to find and request the GPIOs then being utilized
to select and deselect the channels of GPIO-driven i2c-muxes. Even
though the proposed modification was correct for the platform_data-based
systems, it was invalid for the OF-based ones and caused the kernel
to crash at the driver probe procedure. There were two problems with
that modification. First of all the gpiod_count() and gpiod_get_index()
were called with NULL con_id. Due to this the methods couldn't find
the "mux-gpios" OF-properties and returned the -ENOENT error. Secondly
the return value of gpiod_count() wasn't checked for being negative,
which in case of an error caused the driver to crash. This patch
is intended to fix the described problems.

Fixes: - ("i2c: mux/i801: Switch to use descriptor passing")
Cc: Mika Westerberg <mika.westerberg@...ux.intel.com>
Cc: Andy Shevchenko <andriy.shevchenko@...ux.intel.com>
Cc: Peter Rosin <peda@...ntia.se>
Cc: Jean Delvare <jdelvare@...e.com>
Cc: Linus Walleij <linus.walleij@...aro.org>
Signed-off-by: Serge Semin <fancer.lancer@...il.com>
---
 drivers/i2c/busses/i2c-i801.c    |  2 +-
 drivers/i2c/muxes/i2c-mux-gpio.c | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/i2c/busses/i2c-i801.c b/drivers/i2c/busses/i2c-i801.c
index a377d94968af..ec54b5b4f1a1 100644
--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -1276,7 +1276,7 @@ static int i801_add_mux(struct i801_priv *priv)
 	for (i = 0; i < mux_config->n_gpios; i++) {
 		lookup->table[i].chip_label = mux_config->gpio_chip;
 		lookup->table[i].chip_hwnum = mux_config->gpios[i];
-		lookup->table[i].con_id = NULL;
+		lookup->table[i].con_id = "mux";
 	}
 	gpiod_add_lookup_table(lookup);
 	priv->lookup = lookup;
diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c
index b9578f668fb2..1ea097dc8d5d 100644
--- a/drivers/i2c/muxes/i2c-mux-gpio.c
+++ b/drivers/i2c/muxes/i2c-mux-gpio.c
@@ -130,10 +130,10 @@ static int i2c_mux_gpio_probe(struct platform_device *pdev)
 			sizeof(mux->data));
 	}
 
-	ngpios = gpiod_count(&pdev->dev, NULL);
-	if (!ngpios) {
-		dev_err(&pdev->dev, "no gpios provided\n");
-		return -EINVAL;
+	ngpios = gpiod_count(&pdev->dev, "mux");
+	if (ngpios <= 0) {
+		dev_err(&pdev->dev, "no valid gpios provided\n");
+		return ngpios ?: -EINVAL;
 	}
 	mux->ngpios = ngpios;
 
@@ -173,7 +173,7 @@ static int i2c_mux_gpio_probe(struct platform_device *pdev)
 			flag = GPIOD_OUT_HIGH;
 		else
 			flag = GPIOD_OUT_LOW;
-		gpiod = devm_gpiod_get_index(&pdev->dev, NULL, i, flag);
+		gpiod = devm_gpiod_get_index(&pdev->dev, "mux", i, flag);
 		if (IS_ERR(gpiod)) {
 			ret = PTR_ERR(gpiod);
 			goto alloc_failed;
-- 
2.21.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ