[Devel,2/3] ns: Silence coverity warning in do_create_pid_ns_helper()

Submitted by Kirill Tkhai on June 21, 2017, 10:34 a.m.

Details

Message ID 149804128118.7468.14668045027627564577.stgit@localhost.localdomain
State New
Series "Series without cover letter"
Headers show

Commit Message

Kirill Tkhai June 21, 2017, 10:34 a.m.
------------------------------------------------------------------------------
*** CID 181219:  Null pointer dereferences  (NULL_RETURNS)
/criu/namespaces.c: 2690 in do_create_pid_ns_helper()
2684            struct pid *pid;
2685            pid_t child;
2686
2687            ns_reaper = *(struct pstree_item **)arg;
2688            ns = lookup_ns_by_id(ns_reaper->ids->pid_ns_id, &pid_ns_desc);
2689
>>>     CID 181219:  Null pointer dereferences  (NULL_RETURNS)
>>>     Dereferencing a null pointer "ns".
2690            pid = __pstree_pid_by_virt(ns, ns->ns_pid);
2691            if (!pid) {
2692                    pr_err("Can't find helper reserved pid\n");
2693                    goto close_sk;
2694            }
------------------------------------------------------------------------------

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 criu/namespaces.c |    1 +
 1 file changed, 1 insertion(+)

Patch hide | download patch | download mbox

diff --git a/criu/namespaces.c b/criu/namespaces.c
index 15de9c515..812edc209 100644
--- a/criu/namespaces.c
+++ b/criu/namespaces.c
@@ -2686,6 +2686,7 @@  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);
+	BUG_ON(!ns);
 
 	pid = __pstree_pid_by_virt(ns, ns->ns_pid);
 	if (!pid) {