diff --git a/include/linux/ns_common.h b/include/linux/ns_common.h index bd4492ef6ffc..b22c692b5f38 100644 --- a/include/linux/ns_common.h +++ b/include/linux/ns_common.h @@ -289,7 +289,10 @@ static __always_inline void __ns_ref_active_get(struct ns_common *ns) VFS_WARN_ON_ONCE(is_initial_namespace(ns) && __ns_ref_active_read(ns) <= 0); } #define ns_ref_active_get(__ns) \ - do { if (__ns) __ns_ref_active_get(to_ns_common(__ns)); } while (0) + do { \ + if ((__ns) && !is_initial_namespace(&(__ns)->ns)) \ + __ns_ref_active_get(to_ns_common(__ns)); \ + } while (0) static __always_inline bool __ns_ref_active_get_not_zero(struct ns_common *ns) { @@ -314,7 +317,10 @@ static __always_inline void __ns_ref_active_put(struct ns_common *ns) } } #define ns_ref_active_put(__ns) \ - do { if (__ns) __ns_ref_active_put(to_ns_common(__ns)); } while (0) + do { \ + if ((__ns) && !is_initial_namespace(&(__ns)->ns)) \ + __ns_ref_active_put(to_ns_common(__ns)); \ + } while (0) static __always_inline struct ns_common *__must_check ns_get_unless_inactive(struct ns_common *ns) {