aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpiolib.c
diff options
context:
space:
mode:
authorDan Carpenter <error27@gmail.com>2010-04-27 17:12:03 -0400
committerGrant Likely <grant.likely@secretlab.ca>2010-04-28 02:50:01 -0400
commit3913fd5ed42c990c20036ef5c90e7987a9dd1ad1 (patch)
treea3f4236246c3ffd65d71571c1f41615c3f4e24fc /drivers/gpio/gpiolib.c
parent01bf0b64579ead8a82e7cfc32ae44bc667e7ad0f (diff)
gpio: potential null dereference
Smatch found a potential null dereference in gpio_setup_irq(). The "pdesc" variable is allocated with idr_find() that can return NULL. If gpio_setup_irq() is called with 0 as gpio_flags and "pdesc" is null, it would OOPs here. Signed-off-by: Dan Carpenter <error27@gmail.com> Cc: David Brownell <david-b@pacbell.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r--drivers/gpio/gpiolib.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 76be229c814d..eb0c3fe44b29 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -416,7 +416,8 @@ static int gpio_setup_irq(struct gpio_desc *desc, struct device *dev,
416 return 0; 416 return 0;
417 417
418free_sd: 418free_sd:
419 sysfs_put(pdesc->value_sd); 419 if (pdesc)
420 sysfs_put(pdesc->value_sd);
420free_id: 421free_id:
421 idr_remove(&pdesc_idr, id); 422 idr_remove(&pdesc_idr, id);
422 desc->flags &= GPIO_FLAGS_MASK; 423 desc->flags &= GPIO_FLAGS_MASK;