* [PATCH AUTOSEL 5.0 55/98] gpio: aspeed: fix a potential NULL pointer dereference
[not found] <20190422194205.10404-1-sashal@kernel.org>
@ 2019-04-22 19:41 ` Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 77/98] gpio: of: Check propname before applying "cs-gpios" quirks Sasha Levin
` (2 subsequent siblings)
3 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2019-04-22 19:41 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Kangjie Lu, Bartosz Golaszewski, Sasha Levin, linux-gpio
From: Kangjie Lu <kjlu@umn.edu>
[ Upstream commit 6cf4511e9729c00a7306cf94085f9cc3c52ee723 ]
In case devm_kzalloc, the patch returns ENOMEM to avoid potential
NULL pointer dereference.
Signed-off-by: Kangjie Lu <kjlu@umn.edu>
Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Signed-off-by: Sasha Levin (Microsoft) <sashal@kernel.org>
---
drivers/gpio/gpio-aspeed.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpio/gpio-aspeed.c b/drivers/gpio/gpio-aspeed.c
index 854bce4fb9e7..217507002dbc 100644
--- a/drivers/gpio/gpio-aspeed.c
+++ b/drivers/gpio/gpio-aspeed.c
@@ -1224,6 +1224,8 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev)
gpio->offset_timer =
devm_kzalloc(&pdev->dev, gpio->chip.ngpio, GFP_KERNEL);
+ if (!gpio->offset_timer)
+ return -ENOMEM;
return aspeed_gpio_setup_irqs(gpio, pdev);
}
--
2.19.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH AUTOSEL 5.0 77/98] gpio: of: Check propname before applying "cs-gpios" quirks
[not found] <20190422194205.10404-1-sashal@kernel.org>
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 55/98] gpio: aspeed: fix a potential NULL pointer dereference Sasha Levin
@ 2019-04-22 19:41 ` Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 78/98] gpio: of: Check for "spi-cs-high" in child instead of parent node Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 87/98] gpio: of: Fix of_gpiochip_add() error path Sasha Levin
3 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2019-04-22 19:41 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Andrey Smirnov, Linus Walleij, Bartosz Golaszewski, Chris Healy,
linux-gpio, Sasha Levin
From: Andrey Smirnov <andrew.smirnov@gmail.com>
[ Upstream commit e5545c94e43b8f6599ffc01df8d1aedf18ee912a ]
SPI GPIO device has more than just "cs-gpio" property in its node and
would request those GPIOs as a part of its initialization. To avoid
applying CS-specific quirk to all of them add a check to make sure
that propname is "cs-gpios".
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Cc: Chris Healy <cphealy@gmail.com>
Cc: linux-gpio@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sasha Levin (Microsoft) <sashal@kernel.org>
---
drivers/gpio/gpiolib-of.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index a1dd2f1c0d02..9470563f2506 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -119,7 +119,8 @@ static void of_gpio_flags_quirks(struct device_node *np,
* to determine if the flags should have inverted semantics.
*/
if (IS_ENABLED(CONFIG_SPI_MASTER) &&
- of_property_read_bool(np, "cs-gpios")) {
+ of_property_read_bool(np, "cs-gpios") &&
+ !strcmp(propname, "cs-gpios")) {
struct device_node *child;
u32 cs;
int ret;
--
2.19.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH AUTOSEL 5.0 78/98] gpio: of: Check for "spi-cs-high" in child instead of parent node
[not found] <20190422194205.10404-1-sashal@kernel.org>
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 55/98] gpio: aspeed: fix a potential NULL pointer dereference Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 77/98] gpio: of: Check propname before applying "cs-gpios" quirks Sasha Levin
@ 2019-04-22 19:41 ` Sasha Levin
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 87/98] gpio: of: Fix of_gpiochip_add() error path Sasha Levin
3 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2019-04-22 19:41 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Andrey Smirnov, Linus Walleij, Bartosz Golaszewski, Chris Healy,
linux-gpio, Sasha Levin
From: Andrey Smirnov <andrew.smirnov@gmail.com>
[ Upstream commit 7ce40277bf848391705011ba37eac2e377cbd9e6 ]
"spi-cs-high" is going to be specified in child node of an SPI
controller's representing attached SPI device, so change the code to
look for it there, instead of checking parent node.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Cc: Chris Healy <cphealy@gmail.com>
Cc: linux-gpio@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sasha Levin (Microsoft) <sashal@kernel.org>
---
drivers/gpio/gpiolib-of.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index 9470563f2506..f1ae28289a67 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -142,16 +142,16 @@ static void of_gpio_flags_quirks(struct device_node *np,
* conflict and the "spi-cs-high" flag will
* take precedence.
*/
- if (of_property_read_bool(np, "spi-cs-high")) {
+ if (of_property_read_bool(child, "spi-cs-high")) {
if (*flags & OF_GPIO_ACTIVE_LOW) {
pr_warn("%s GPIO handle specifies active low - ignored\n",
- of_node_full_name(np));
+ of_node_full_name(child));
*flags &= ~OF_GPIO_ACTIVE_LOW;
}
} else {
if (!(*flags & OF_GPIO_ACTIVE_LOW))
pr_info("%s enforce active low on chipselect handle\n",
- of_node_full_name(np));
+ of_node_full_name(child));
*flags |= OF_GPIO_ACTIVE_LOW;
}
break;
--
2.19.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH AUTOSEL 5.0 87/98] gpio: of: Fix of_gpiochip_add() error path
[not found] <20190422194205.10404-1-sashal@kernel.org>
` (2 preceding siblings ...)
2019-04-22 19:41 ` [PATCH AUTOSEL 5.0 78/98] gpio: of: Check for "spi-cs-high" in child instead of parent node Sasha Levin
@ 2019-04-22 19:41 ` Sasha Levin
3 siblings, 0 replies; 4+ messages in thread
From: Sasha Levin @ 2019-04-22 19:41 UTC (permalink / raw)
To: linux-kernel, stable
Cc: Geert Uytterhoeven, Linus Walleij, Sasha Levin, linux-gpio
From: Geert Uytterhoeven <geert+renesas@glider.be>
[ Upstream commit f7299d441a4da8a5088e651ea55023525a793a13 ]
If the call to of_gpiochip_scan_gpios() in of_gpiochip_add() fails, no
error handling is performed. This lead to the need of callers to call
of_gpiochip_remove() on failure, which causes "BAD of_node_put() on ..."
if the failure happened before the call to of_node_get().
Fix this by adding proper error handling.
Note that calling gpiochip_remove_pin_ranges() multiple times causes no
harm: subsequent calls are a no-op.
Fixes: dfbd379ba9b7431e ("gpio: of: Return error if gpio hog configuration failed")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Sasha Levin (Microsoft) <sashal@kernel.org>
---
drivers/gpio/gpiolib-of.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index f1ae28289a67..13a402ede07a 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -712,7 +712,13 @@ int of_gpiochip_add(struct gpio_chip *chip)
of_node_get(chip->of_node);
- return of_gpiochip_scan_gpios(chip);
+ status = of_gpiochip_scan_gpios(chip);
+ if (status) {
+ of_node_put(chip->of_node);
+ gpiochip_remove_pin_ranges(chip);
+ }
+
+ return status;
}
void of_gpiochip_remove(struct gpio_chip *chip)
--
2.19.1
^ permalink raw reply related [flat|nested] 4+ messages in thread