[CRIU] [PATCH 13/18] namespaces: prevent dereferencing a null pointer

Andrei Vagin avagin at openvz.org
Thu Nov 9 22:21:07 MSK 2017


From: Andrei Vagin <avagin at virtuozzo.com>

CID 181219 (#1 of 1): Dereference null return value (NULL_RETURNS)
3. dereference: Dereferencing a null pointer ns.

Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
 criu/namespaces.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/criu/namespaces.c b/criu/namespaces.c
index 5c4697641..4a3709bc3 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -2667,6 +2667,10 @@ static int do_create_pid_ns_helper(void *arg, int sk, pid_t unused_pid)
 
 	ns_reaper = *(struct pstree_item **)arg;
 	ns = lookup_ns_by_id(ns_reaper->ids->pid_ns_id, &pid_ns_desc);
+	if (ns == NULL) {
+		pr_err("Unable to find a pid namespace %d\n", ns_reaper->ids->pid_ns_id);
+		goto close_sk;
+	}
 
 	pid = __pstree_pid_by_virt(ns, ns->ns_pid);
 	if (!pid) {
-- 
2.13.6



More information about the CRIU mailing list