From: Dan Carpenter Date: Tue, 27 Apr 2010 21:12:03 +0000 (-0700) Subject: gpio: potential null dereference X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3913fd5ed42c990c20036ef5c90e7987a9dd1ad1;p=GitHub%2Fmt8127%2Fandroid_kernel_alcatel_ttab.git 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 Cc: David Brownell Signed-off-by: Andrew Morton Signed-off-by: Grant Likely --- 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, return 0; free_sd: - sysfs_put(pdesc->value_sd); + if (pdesc) + sysfs_put(pdesc->value_sd); free_id: idr_remove(&pdesc_idr, id); desc->flags &= GPIO_FLAGS_MASK;