From: "Daniel Glöckner" <dg@emlix.com>
To: Dan Carpenter <error27@gmail.com>,
Andrew Morton <akpm@linux-foundation.org>,
Jani Nikula <ext-jani.1.nikula@nokia.com>,
David Brownell <dbrownell@users.sourceforge.net>,
Andi Kleen <ak@linux.intel.com>,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [patch] gpio: potential null dereference
Date: Mon, 26 Apr 2010 23:05:15 +0000 [thread overview]
Message-ID: <20100426230515.GA1388@emlix.com> (raw)
In-Reply-To: <20100426192520.GU29093@bicker>
On Mon, Apr 26, 2010 at 09:25:20PM +0200, Dan Carpenter wrote:
> 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.
idr_find() doesn't allocate, idr_get_new_above() does.
Assuming idr_find() never fails for an id if idr_get_new_above()
successfully allocated that id, I don't think we can reach that
line with pdesc being NULL:
- There are two gotos leading to free_sd
- #2 is after a block that allocates pdesc
- #1 is in an if (!gpio_flags) block
- We exit early if ((desc->flags & GPIO_TRIGGER_MASK) = gpio_flags)
- Therefore (desc->flags & GPIO_TRIGGER_MASK) must be != 0 to reach #1
- Trigger flags are added to desc->flags only after we have
successfully allocated pdesc (i.e. right before return 0)
- We start off with no trigger flags set
Daniel
--
Dipl.-Math. Daniel Glöckner, emlix GmbH, http://www.emlix.com
Fon +49 551 30664-0, Fax -11, Bahnhofsallee 1b, 37081 Göttingen, Germany
Sitz der Gesellschaft: Göttingen, Amtsgericht Göttingen HR B 3160
Geschäftsführung: Dr. Uwe Kracke, Ust-IdNr.: DE 205 198 055
emlix - your embedded linux partner
--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2010-04-26 23:05 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-04-26 19:25 [patch] gpio: potential null dereference Dan Carpenter
2010-04-26 23:05 ` Daniel Glöckner [this message]
2010-04-26 23:14 ` Andrew Morton
2010-04-27 9:05 ` Dan Carpenter
2010-04-27 9:41 ` Daniel Glöckner
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=20100426230515.GA1388@emlix.com \
--to=dg@emlix.com \
--cc=ak@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=dbrownell@users.sourceforge.net \
--cc=error27@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).