On Mon, Mar 28, 2005 at 10:23:48PM -0800, Andrew Morton wrote:
> >  > -        int old=card->amplifier;
> >  > +        int old;
> >  >          if(!card)
> >  >          {
> >  >                  CS_DBGOUT(CS_ERROR, 2, printk(KERN_INFO 
> >  >                          "cs46xx: amp_hercules() called before 
> > initialized.\n"));
> >  >                  return;
> >  >          }
> >  > +        old = card->amplifier;

> No, there is a third case: the pointer can be NULL, but the compiler
> happened to move the dereference down to after the check.
> 
> If the optimiser is later changed, or if someone tries to compile the code
> with -O0, it will oops.

The thing GCC is most likely to do with this code is discard the NULL
check entirely and leave only the oops; the "if (!card)" can not be
reached without passing through "card->amplifier", and a pointer which
is dereferenced can not be NULL in a valid program.

-- 
Daniel Jacobowitz
CodeSourcery, LLC
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to