Gracefully handle the case if current->nsproxy is NULL:
check for the condition and return an error, avoiding attempts
to dereference the pointer.
Lustre-change: https://review.whamcloud.com/36802
Lustre-commit:
15278c6d32a5a9a7a2b8ac9e08c8702383e0c2ff
Signed-off-by: Serguei Smirnov <ssmirnov@whamcloud.com>
Change-Id: Ia102d2bacdb0e54b0339985396447e6d25465c56
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Signed-off-by: Minh Diep <mdiep@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/37314
Tested-by: jenkins <devops@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
#endif
#ifdef HAVE_PID_NS_FOR_CHILDREN
-# define ll_task_pid_ns(task) ((task)->nsproxy->pid_ns_for_children)
+# define ll_task_pid_ns(task) \
+ ((task)->nsproxy ? ((task)->nsproxy->pid_ns_for_children) : NULL)
#else
-# define ll_task_pid_ns(task) ((task)->nsproxy->pid_ns)
+# define ll_task_pid_ns(task) \
+ ((task)->nsproxy ? ((task)->nsproxy->pid_ns) : NULL)
#endif
#ifdef HAVE_FULL_NAME_HASH_3ARGS
init_waitqueue_head(&imp->imp_recovery_waitq);
INIT_WORK(&imp->imp_zombie_work, obd_zombie_imp_cull);
- if (curr_pid_ns->child_reaper)
+ if (curr_pid_ns && curr_pid_ns->child_reaper)
imp->imp_sec_refpid = curr_pid_ns->child_reaper->pid;
else
imp->imp_sec_refpid = 1;
* used outside of the kernel itself, because it calls
* free_nsproxy() which is not exported by the kernel
* (defined in kernel/nsproxy.c) */
- atomic_dec(&curr_ns->count);
+ if (curr_ns)
+ atomic_dec(&curr_ns->count);
}
task_unlock(lpi->lpi_reftask);