lkml.org 
[lkml]   [2010]   [Apr]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    Date
    From
    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@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;

    \
     
     \ /
      Last update: 2010-04-26 21:27    [W:7.825 / U:0.028 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site