Subject: Re: Bug in usr/src/sys/net/radix.c on 3.0?
To: None <tech-kern@netbsd.org>
From: Christos Zoulas <christos@astron.com>
List: tech-kern
Date: 05/04/2006 19:58:45
In article <445A38EE.3050803@redback.com>,
Markus Mayer <mmayer@redback.com> wrote:
>Hi,
>
>I just noticed looking at the code in radix.c that there seems to be the
>possibility that this module may not initialize properly:
>
>void
>rn_init()
>{
> char *cp, *cplim;
>#ifdef _KERNEL
> static int initialized;
> __link_set_decl(domains, struct domain);
> struct domain *const *dpp;
>
> if (initialized)
> return;
> initialized = 1;
>[...]
>
>
>The static variable 'initialized' is never explicitly set to 0 in the
>beginning. Hence it is possible that 'initialized' has a value other
>than 0 when the system starts up and thus the 'if' statement might be
>true even though the rest of the code has never been executed.
>
>I am suggesting to do something like this:
>
>diff -u -r1.28 radix.c
>--- radix.c 26 Feb 2005 22:45:09 -0000 1.28
>+++ radix.c 4 May 2006 17:19:09 -0000
>@@ -945,7 +945,7 @@
> {
> char *cp, *cplim;
> #ifdef _KERNEL
>- static int initialized;
>+ static int initialized = 0;
> __link_set_decl(domains, struct domain);
> struct domain *const *dpp;
>
If that is the case, then your linker is broken.
christos