All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] gpio: potential null dereference
@ 2010-04-26 19:25 ` Dan Carpenter
  0 siblings, 0 replies; 12+ messages in thread
From: Dan Carpenter @ 2010-04-26 19:25 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Jani Nikula, David Brownell, Daniel Glöckner, Andi Kleen,
	linux-kernel, kernel-janitors

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>

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 76be229..eb0c3fe 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;

^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2010-04-27 10:34 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-26 19:25 [patch] gpio: potential null dereference Dan Carpenter
2010-04-26 19:25 ` Dan Carpenter
2010-04-26 23:05 ` Daniel Glöckner
2010-04-26 23:05   ` Daniel Glöckner
2010-04-26 23:14   ` Andrew Morton
2010-04-26 23:14     ` Andrew Morton
2010-04-27  9:05   ` Dan Carpenter
2010-04-27  9:05     ` Dan Carpenter
2010-04-27  9:41     ` Daniel Glöckner
2010-04-27  9:41       ` Daniel Glöckner
2010-04-27 10:30       ` Dan Carpenter
2010-04-27 10:30         ` Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.