diff options
| author | Eric W. Biederman <ebiederm@xmission.com> | 2012-01-26 09:02:55 -0500 |
|---|---|---|
| committer | Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com> | 2012-02-13 15:15:06 -0500 |
| commit | bbea07382e4b5260a1a878a31c2be2db9c09fd94 (patch) | |
| tree | 05f47e8c028eb895762f7f13a87407e8654844ac /include/net | |
| parent | c27b65ee80163095313ec7f9a33507162ae64fd7 (diff) | |
netns: Fail conspicously if someone uses net_generic at an inappropriate time.
BugLink: http://bugs.launchpad.net/bugs/926309
[ 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: Tim Gardner <tim.gardner@canonical.com>
Diffstat (limited to 'include/net')
| -rw-r--r-- | include/net/netns/generic.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/include/net/netns/generic.h b/include/net/netns/generic.h index 3419bf5cd15..d55f4344333 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) | |||
| 41 | ptr = ng->ptr[id - 1]; | 41 | ptr = ng->ptr[id - 1]; |
| 42 | rcu_read_unlock(); | 42 | rcu_read_unlock(); |
| 43 | 43 | ||
| 44 | BUG_ON(!ptr); | ||
| 44 | return ptr; | 45 | return ptr; |
| 45 | } | 46 | } |
| 46 | #endif | 47 | #endif |
