Re: Do not misuse Coverity please (Was: sound/oss/cs46xx.c: fix a check after use)

From: Jean Delvare (khali_at_linux-fr.org)
Date: 03/29/05

  • Next message: Martin Mares: "Re: [PATCH] API for true Random Number Generators to add entropy (2.6.11)"
    Date:	Tue, 29 Mar 2005 12:46:22 +0200 (CEST)
    To: akpm@osdl.org
    
    

    Hi Andrew, all,

    > > Think about it. If the pointer could be NULL, then it's unlikely that
    > > the bug would have gone unnoticed so far (unless the code is very
    > > recent). Coverity found 3 such bugs in one i2c driver [1], and the
    > > correct solution was to NOT check for NULL because it just couldn't
    > > happen.
    >
    > No, there is a third case: the pointer can be NULL, but the compiler
    > happened to move the dereference down to after the check.

    Wow. Great point. I completely missed that possibility. In fact I didn't
    know that the compiler could possibly alter the order of the
    instructions. For one thing, I thought it was simply not allowed to. For
    another, I didn't know that it had been made so aware that it could
    actually figure out how to do this kind of things. What a mess. Let's
    just hope that the gcc folks know their business :)

    I'll try to remember this next time I debug something. Do not assume
    that instructions are run in the order seen in the source. Irk.

    > If the optimiser is later changed, or if someone tries to compile the code
    > with -O0, it will oops.

    Interesting. Then wouldn't it be worth attempting such compilations at
    times, and see if we get additional oops? Doesn't gcc have a flag to
    specifically forbid this family of optimizations?

    Thanks,

    --
    Jean Delvare
    -
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to majordomo@vger.kernel.org
    More majordomo info at  http://vger.kernel.org/majordomo-info.html
    Please read the FAQ at  http://www.tux.org/lkml/
    

  • Next message: Martin Mares: "Re: [PATCH] API for true Random Number Generators to add entropy (2.6.11)"

    Relevant Pages

    • Re: Oops linux 2.4.23-pre6 on amd64
      ... >>Oops, scratch that last one... ... It's invalid too as I used the original ... falling over with internal compiler errors/segfaults/etc.). ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: XFS corruption on move from xscale to i686
      ... just fix your compiler or let the gcc folks do it. ... > the arm folks ever open a PR at the gcc bugzilla with a reproduced ... You're never get your compiler fixed with that attitude. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: [discuss] booting a kernel compiled with -mregparm=0
      ... > this one) and even if GCC produced valid code by miracle, ... That's the default for a 'C' compiler (not to pass parameters ... This forced some parameters to be passed in registers, ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: PATCH, RFC: 2.6 Documentation/Codingstyle
      ... Giuliano Pochini wrote: ... A compiler should do it, a maintainer IMHO should not for a really simple ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)
    • Re: ALSA vs. OSS
      ... Loading the kernel version of the modules always fails with: ... perhaps from the compiler, which I compiled myself: ... gcc 2.95.3) and binutils 2.14. ... send the line "unsubscribe linux-kernel" in ...
      (Linux-Kernel)

    Loading