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 <[email protected]>
Cc: David Brownell <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Grant Likely <[email protected]>
This commit is contained in:
Dan Carpenter 2010-04-27 14:12:03 -07:00 • committed by Grant Likely
commit 3913fd5ed4

View file

@ -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;