lkml.org 
[lkml]   [2016]   [Oct]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] gpio: gpiolib-devprop: Check chip->parent pointer before dereferencing
Date
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(+)

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)
--
1.9.1
\
 
 \ /
  Last update: 2016-10-25 18:25    [W:0.043 / U:0.732 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site