All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <error27@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Jani Nikula" <ext-jani.1.nikula@nokia.com>,
	"David Brownell" <dbrownell@users.sourceforge.net>,
	"Daniel Glöckner" <dg@emlix.com>,
	"Andi Kleen" <ak@linux.intel.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch] gpio: potential null dereference
Date: Mon, 26 Apr 2010 19:25:20 +0000	[thread overview]
Message-ID: <20100426192520.GU29093@bicker> (raw)

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;

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <error27@gmail.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: "Jani Nikula" <ext-jani.1.nikula@nokia.com>,
	"David Brownell" <dbrownell@users.sourceforge.net>,
	"Daniel Glöckner" <dg@emlix.com>,
	"Andi Kleen" <ak@linux.intel.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: [patch] gpio: potential null dereference
Date: Mon, 26 Apr 2010 21:25:20 +0200	[thread overview]
Message-ID: <20100426192520.GU29093@bicker> (raw)

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;

             reply	other threads:[~2010-04-26 19:25 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-26 19:25 Dan Carpenter [this message]
2010-04-26 19:25 ` [patch] gpio: potential null dereference 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100426192520.GU29093@bicker \
    --to=error27@gmail.com \
    --cc=ak@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=dbrownell@users.sourceforge.net \
    --cc=dg@emlix.com \
    --cc=ext-jani.1.nikula@nokia.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.