Fix: statedump: consistently check task_cred_xxx() return value for NULL
[lttng-modules.git] / lttng-statedump-impl.c
index a707c775dd683a8b6dff99b53049349ddea43fdf..2ead9b6f12c1f99b7701d233a5c482d7a008e686 100644 (file)
@@ -425,17 +425,24 @@ void lttng_statedump_process_ns(struct lttng_session *session,
         */
        pid_ns = task_active_pid_ns(p);
        do {
-               trace_lttng_statedump_process_state(session,
-                       p, type, mode, submode, status, pid_ns);
                trace_lttng_statedump_process_pid_ns(session, p, pid_ns);
-               pid_ns = pid_ns->parent;
+               pid_ns = pid_ns ? pid_ns->parent : NULL;
        } while (pid_ns);
 
 
        user_ns = task_cred_xxx(p, user_ns);
        do {
                trace_lttng_statedump_process_user_ns(session, p, user_ns);
-               user_ns = user_ns->lttng_user_ns_parent;
+               /*
+                * trace_lttng_statedump_process_user_ns() internally
+                * checks whether user_ns is NULL. While this does not
+                * appear to be a possible return value for
+                * task_cred_xxx(), err on the safe side and check
+                * for NULL here as well to be consistent with the
+                * paranoid behavior of
+                * trace_lttng_statedump_process_user_ns().
+                */
+               user_ns = user_ns ? user_ns->lttng_user_ns_parent : NULL;
        } while (user_ns);
 
        /*
@@ -523,6 +530,9 @@ int lttng_enumerate_process_states(struct lttng_session *session)
                                type = LTTNG_USER_THREAD;
                        else
                                type = LTTNG_KERNEL_THREAD;
+
+                       trace_lttng_statedump_process_state(session,
+                               p, type, mode, submode, status);
                        lttng_statedump_process_ns(session,
                                p, type, mode, submode, status);
                        task_unlock(p);
This page took 0.023254 seconds and 4 git commands to generate.