mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ingo Molnar <mingo@kernel.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
	Anna-Maria Gleixner <anna-maria@linutronix.de>,
	Boris Ostrovsky <boris.ostrovsky@oracle.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] rcu: remove unused variable in boot_cpu_state_init
Date: Thu, 22 Jun 2017 11:02:41 +0200	[thread overview]
Message-ID: <20170622090241.3cwwfesg7c43lgbq@gmail.com> (raw)
In-Reply-To: <CAK8P3a3_yRSYq0nezytp632Yz6gHgOqTm+csCXpLvO2XqyXWDg@mail.gmail.com>


* Arnd Bergmann <arnd@arndb.de> wrote:

> On Thu, Jun 22, 2017 at 9:59 AM, Ingo Molnar <mingo@kernel.org> wrote:
> >
> > So, to continue this side thought about uninitialized_var(), it is dangerous
> > because the following buggy pattern does not generate a compiler warning:
> >
> >         long uninitialized_var(error);
> >
> >         ...
> >
> >         if (error)
> >                 return error;
> >
> >
> > ... and still there are over 290 uses of uninitialized_var() in the kernel - and
> > any of them could turn into a silent but real uninitialized variable bugs due to
> > subsequent changes.
> 
> Right, absolutely agreed on that. A related problem however is blindly
> initializing variables to NULL to get rid of uninitialized variable warnings,
> such as
> 
>       struct subsystem_specific *obj = NULL;
>       if (function_argument > 10)
>               goto err;
>      obj = create_obj();
> ...
> err:
>       clean_up(obj->member);
> 
> 
> I've seen a couple of variations of that problem, so simply outlawing
> uninitialized_var() will only solve a subset of these issues, and ideally
> we should also make sure that initializations at declaration time are
> used properly, and not just to shut up compiler warnings.

Well, a deterministic crash on a NULL dereference is still (much) better than a 
non-deterministic 'use random value from stack and corrupt memory or crash' bug 
pattern, right?

Also, static analysis tools ought to be pretty good about finding control flows 
where a NULL gets dereferenced.

Thanks,

	Ingo

  reply	other threads:[~2017-06-22  9:02 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-21 21:57 Arnd Bergmann
2017-06-21 22:10 ` Paul E. McKenney
2017-06-21 22:15   ` Arnd Bergmann
2017-06-22 14:36     ` Paul E. McKenney
2017-06-22 21:10       ` Paul E. McKenney
2017-06-22  7:26   ` Ingo Molnar
2017-06-22  7:41     ` Arnd Bergmann
2017-06-22  7:51       ` Ingo Molnar
2017-06-22  7:54         ` Ingo Molnar
2017-06-22  7:59           ` Ingo Molnar
2017-06-22  8:58             ` Arnd Bergmann
2017-06-22  9:02               ` Ingo Molnar [this message]
2017-06-22  9:44                 ` Arnd Bergmann
2017-06-22 14:55     ` Paul E. McKenney

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=20170622090241.3cwwfesg7c43lgbq@gmail.com \
    --to=mingo@kernel.org \
    --cc=anna-maria@linutronix.de \
    --cc=arnd@arndb.de \
    --cc=bigeasy@linutronix.de \
    --cc=boris.ostrovsky@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paulmck@linux.vnet.ibm.com \
    --cc=tglx@linutronix.de \
    /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

all inboxes | Powered by JetHome®