From: Roland Dreier <rdreier@cisco.com>
To: lkml@MoreThan.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: [Compile Warning] 2.6.30-rc8 build
Date: Fri, 05 Jun 2009 10:22:09 -0700 [thread overview]
Message-ID: <ada63fawq7y.fsf@cisco.com> (raw)
In-Reply-To: <200906051143.06119.lkml@morethan.org> (Michael S. Zick's message of "Fri, 5 Jun 2009 11:43:03 -0500")
> To my reading of the function, I think gcc has a point:
>
> drivers/serial/8250.c: In function 'serial8250_shutdown':
> drivers/serial/8250.c:1685: warning: 'i' may be used uninitialized in this function
>
> It does read as if the code might try to initialize
> the 'lock' field of a null pointer.
The code in question is:
static void serial_unlink_irq_chain(struct uart_8250_port *up)
{
struct irq_info *i;
struct hlist_node *n;
struct hlist_head *h;
mutex_lock(&hash_mutex);
h = &irq_lists[up->port.irq % NR_IRQ_HASH];
hlist_for_each(n, h) {
i = hlist_entry(n, struct irq_info, node);
if (i->irq == up->port.irq)
break;
}
BUG_ON(n == NULL);
BUG_ON(i->head == NULL);
if (list_empty(i->head))
free_irq(up->port.irq, i);
and if the hlist_for_each() doesn't find a matching irq_info to put in
i, then the BUG_ON(n == NULL) will kill the system. So there's no bug
although it is understandable that gcc can't see that.
(Not sure why you talk about "the 'lock' field of a null pointer" -- I
assume your gcc warns about the function serial8250_shutdown() because
it is inlining a function only called from a single location)
- R.
next prev parent reply other threads:[~2009-06-05 17:22 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-05 16:43 [Compile Warning] 2.6.30-rc8 build Michael S. Zick
2009-06-05 17:22 ` Roland Dreier [this message]
2009-06-05 17:40 ` Michael S. Zick
2009-06-05 17:50 ` Roland Dreier
2009-06-05 18:06 ` Alan Cox
2009-06-05 18:01 ` Alan Cox
2009-06-05 21:57 ` Andrew Morton
2009-06-05 22:06 ` Alan Cox
2009-06-05 22:13 ` Andrew Morton
-- strict thread matches above, loose matches on Subject: below --
2009-06-05 16:50 Michael S. Zick
2009-06-05 17:28 ` Roland Dreier
2009-06-05 17:49 ` Michael S. Zick
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=ada63fawq7y.fsf@cisco.com \
--to=rdreier@cisco.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lkml@MoreThan.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