lkml.org 
[lkml]   [2004]   [Apr]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: Fix UDF-FS potentially dereferencing null
From
Date
On Apr 22, 2004, Linus Torvalds <torvalds@osdl.org> wrote:

> In your example, both pointers were called "p", but they were obviously
> two different symbols from a compiler perspective. So there's a clear
> "assignment" from one "p" to the other "p" as part of the inline function
> call, so it's not like the back-end doesn't see that part - it's assigning
> from a non-safe pointer to a safe one _after_ doing the test on the
> non-safe one.

It does see the assignment, yes, but if the pointer happens to be a
constant, and constant propagation turns the assignment `p_i = p;'
into `p_i = constant;', you'd have to preserve the information that
this constant pointer can only be safely dereferenced after the test.
This is an admittedly convoluted example, since if p is constant and
the condition doesn't hold, the conditional dereferencing will
probably have already been optimized away by the time it could do any
damage, but it might not be depending on how the compiler orders its
optimization passes, and then you lose.

--
Alexandre Oliva http://www.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist oliva@{lsd.ic.unicamp.br, gnu.org}
-
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/

\
 
 \ /
  Last update: 2005-03-22 14:02    [W:0.039 / U:1.372 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site