Commit 5ee4433e authored by Eric W. Biederman's avatar Eric W. Biederman Committed by David S. Miller

netns: Fail conspicously if someone uses net_generic at an inappropriate time.

By definition net_generic should never be called when it can return
NULL.  Fail conspicously with a BUG_ON to make it clear when people mess
up that a NULL return should never happen.

Recently there was a bug in the CAIF subsystem where it was registered
with register_pernet_device instead of register_pernet_subsys.  It was
erroneously concluded that net_generic could validly return NULL and
that net_assign_generic was buggy (when it was just inefficient).
Hopefully this BUG_ON will prevent people to coming to similar erroneous
conclusions in the futrue.
Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
Tested-by: default avatarSasha Levin <levinsasha928@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent cc0d7b91
...@@ -41,6 +41,7 @@ static inline void *net_generic(const struct net *net, int id) ...@@ -41,6 +41,7 @@ static inline void *net_generic(const struct net *net, int id)
ptr = ng->ptr[id - 1]; ptr = ng->ptr[id - 1];
rcu_read_unlock(); rcu_read_unlock();
BUG_ON(!ptr);
return ptr; return ptr;
} }
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment