gpio: potential null dereference

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Friday, April 30, 2010 - 10:59 am

Gitweb:     http://git.kernel.org/linus/3913fd5ed42c990c20036ef5c90e7987a9dd1ad1
Commit:     3913fd5ed42c990c20036ef5c90e7987a9dd1ad1
Parent:     01bf0b64579ead8a82e7cfc32ae44bc667e7ad0f
Author:     Dan Carpenter <error27@gmail.com>
AuthorDate: Tue Apr 27 14:12:03 2010 -0700
Committer:  Grant Likely <grant.likely@secretlab.ca>
CommitDate: Wed Apr 28 00:50:01 2010 -0600

    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>
---
 drivers/gpio/gpiolib.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

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 git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
gpio: potential null dereference, Linux Kernel Mailing ..., (Fri Apr 30, 10:59 am)