[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20100426192520.GU29093@bicker>
Date: Mon, 26 Apr 2010 21:25:20 +0200
From: Dan Carpenter <error27@...il.com>
To: Andrew Morton <akpm@...ux-foundation.org>
Cc: Jani Nikula <ext-jani.1.nikula@...ia.com>,
David Brownell <dbrownell@...rs.sourceforge.net>,
Daniel Glöckner <dg@...ix.com>,
Andi Kleen <ak@...ux.intel.com>, linux-kernel@...r.kernel.org,
kernel-janitors@...r.kernel.org
Subject: [patch] 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@...il.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;
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists