From 1964cccb936a6dec5de336946f904b4b1006560e Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Thu, 20 Feb 2020 10:46:25 -0500 Subject: [PATCH] Fix: statedump: consistently check task_cred_xxx() return value for NULL 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(). Signed-off-by: Mathieu Desnoyers --- lttng-statedump-impl.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lttng-statedump-impl.c b/lttng-statedump-impl.c index 043bbaa1..2ead9b6f 100644 --- a/lttng-statedump-impl.c +++ b/lttng-statedump-impl.c @@ -433,7 +433,16 @@ void lttng_statedump_process_ns(struct lttng_session *session, 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); /* -- 2.34.1