The status variable was declared inside the loop but its value is used
across loop iterations.  When the loop continues and the variable goes
out of scope, its value is referenced leading to undefined behavior.

Found with clang analyze.

Fixes: ff8decf1a318 ("daemon: Add support for process monitoring and restart.")
Signed-off-by: Mike Pattrick <[email protected]>
---
 lib/daemon-unix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/daemon-unix.c b/lib/daemon-unix.c
index 52f977ec8..d14190bce 100644
--- a/lib/daemon-unix.c
+++ b/lib/daemon-unix.c
@@ -347,6 +347,7 @@ monitor_daemon(pid_t daemon_pid)
     time_t last_restart;
     char *status_msg;
     int crashes;
+    int status;
     bool child_ready = true;
 
     set_subprogram_name("monitor");
@@ -355,7 +356,6 @@ monitor_daemon(pid_t daemon_pid)
     crashes = 0;
     for (;;) {
         int retval;
-        int status;
 
         ovs_cmdl_proctitle_set("monitoring pid %lu (%s)",
                                (unsigned long int) daemon_pid, status_msg);
-- 
2.53.0

_______________________________________________
dev mailing list
[email protected]
https://mail.openvswitch.org/mailman/listinfo/ovs-dev

Reply via email to