linux
netpoll_setup() returns an uninitialized value (error code)
Bug fixed by commit e39363a9def
Type | UninitializedVariable |
Config | "NETPOLL && !IPV6" (2nd degree) |
Fix-in | code |
Location | net/ |
__attribute__ ((noinline)) int nondet() { return 42; } #ifdef CONFIG_NETPOLL int netpoll_setup() { int err; #ifdef CONFIG_IPV6 err = -1; if (nondet()) goto put; #else goto put; // (2) #endif put: return err; // ERROR (3) } #endif int main(void) { #ifdef CONFIG_NETPOLL netpoll_setup(); // (1) #endif return 0; }
diff --git a/simple/e39363a.c b/simple/e39363a.c --- a/simple/e39363a.c +++ b/simple/e39363a.c @@ -11,6 +11,7 @@ if (nondet()) goto put; #else + err = -2; goto put; // (2) #endif
#ifdef UNK_TRUE #define unk() 1 #else #include <stdlib.h> #define unk() (rand() % 2) #endif int main() { #ifdef CONFIG_NETPOLL // netpoll_setup(); int err; #ifdef CONFIG_IPV6 err = -1; if (unk()) goto put; #else goto put; #endif put: return err; // ERROR #endif return 0; }
. call net/core/netpoll.c:1045:netpoll_setup() . [!IPV6] 1143: goto put; . ERROR 1162: return err;