summaryrefslogtreecommitdiff
path: root/include/net
diff options
context:
space:
mode:
authorEric W. Biederman <ebiederm@xmission.com>2012-01-26 14:02:55 +0000
committerSimone Willett <swillett@nvidia.com>2012-02-08 14:30:55 -0800
commit7613ba3c7a3232dac09e8ee9092ced867922ad83 (patch)
tree59b408486a034e1bb07918ad4375f47c7da15af0 /include/net
parent68b281810aebe0be4e6142e16fb814c00c6b0f21 (diff)
netns: Fail conspicously if someone uses net_generic at an inappropriate time.
[ Upstream commit 5ee4433efe99b9f39f6eff5052a177bbcfe72cea ] 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: Eric W. Biederman <ebiederm@xmission.com> Tested-by: Sasha Levin <levinsasha928@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Varun Wadekar <vwadekar@nvidia.com> Change-Id: I7936b0403664d9745e4932aad72fd09c100f526c Reviewed-on: http://git-master/r/79690 Reviewed-by: Automatic_Commit_Validation_User
Diffstat (limited to 'include/net')
-rw-r--r--include/net/netns/generic.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/include/net/netns/generic.h b/include/net/netns/generic.h
index 3419bf5cd154..d55f43443335 100644
--- a/include/net/netns/generic.h
+++ b/include/net/netns/generic.h
@@ -41,6 +41,7 @@ static inline void *net_generic(const struct net *net, int id)
ptr = ng->ptr[id - 1];
rcu_read_unlock();
+ BUG_ON(!ptr);
return ptr;
}
#endif