gpio: gpiolib-devprop: Check chip->parent pointer before dereferencing
diff mbox

Message ID 1477413083-9159-1-git-send-email-tthayer@opensource.altera.com
State New
Headers show

Commit Message

tthayer@opensource.altera.com Oct. 25, 2016, 4:31 p.m. UTC
From: Thor Thayer <tthayer@opensource.altera.com>

Confirm the chip->parent is valid before dereferencing because
the parent parameter is optional.

Signed-off-by: Thor Thayer <tthayer@opensource.altera.com>
---
 drivers/gpio/gpiolib-devprop.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Linus Walleij Oct. 25, 2016, 6:24 p.m. UTC | #1
On Tue, Oct 25, 2016 at 6:31 PM,  <tthayer@opensource.altera.com> wrote:

> From: Thor Thayer <tthayer@opensource.altera.com>
>
> Confirm the chip->parent is valid before dereferencing because
> the parent parameter is optional.
>
> Signed-off-by: Thor Thayer <tthayer@opensource.altera.com>

I wish it wasn't. Not much to do about though.

Patch applied.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/drivers/gpio/gpiolib-devprop.c b/drivers/gpio/gpiolib-devprop.c
index 17bfc41..27f383b 100644
--- a/drivers/gpio/gpiolib-devprop.c
+++ b/drivers/gpio/gpiolib-devprop.c
@@ -31,6 +31,11 @@  void devprop_gpiochip_set_names(struct gpio_chip *chip)
 	const char **names;
 	int ret, i;
 
+	if (!chip->parent) {
+		dev_warn(&gdev->dev, "GPIO chip parent is NULL\n");
+		return;
+	}
+
 	ret = device_property_read_string_array(chip->parent, "gpio-line-names",
 						NULL, 0);
 	if (ret < 0)