bridge: check kmem_cache_create() error
authorAkinobu Mita <akinobu.mita@gmail.com>
Sat, 7 Apr 2007 09:57:07 +0000 (18:57 +0900)
committerDavid S. Miller <davem@sunset.davemloft.net>
Thu, 26 Apr 2007 05:28:51 +0000 (22:28 -0700)
This patch checks kmem_cache_create() error and aborts loading module
on failure.

Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>
net/bridge/br.c
net/bridge/br_fdb.c
net/bridge/br_private.h

index 601c37d61c037198ea4908b94bd394d976617f9a..848b8fa8bedd23ee09048ec87e096fc505b6fcb7 100644 (file)
@@ -37,7 +37,9 @@ static int __init br_init(void)
                return -EADDRINUSE;
        }
 
-       br_fdb_init();
+       err = br_fdb_init();
+       if (err)
+               goto err_out1;
 
        err = br_netfilter_init();
        if (err)
index 22645e3edf2343decc265749a5a68f311a6365cd..91b017016d5bcbdd240770f9528706439b91a5f7 100644 (file)
@@ -31,13 +31,17 @@ static int fdb_insert(struct net_bridge *br, struct net_bridge_port *source,
 
 static u32 fdb_salt __read_mostly;
 
-void __init br_fdb_init(void)
+int __init br_fdb_init(void)
 {
        br_fdb_cache = kmem_cache_create("bridge_fdb_cache",
                                         sizeof(struct net_bridge_fdb_entry),
                                         0,
                                         SLAB_HWCACHE_ALIGN, NULL, NULL);
+       if (!br_fdb_cache)
+               return -ENOMEM;
+
        get_random_bytes(&fdb_salt, sizeof(fdb_salt));
+       return 0;
 }
 
 void __exit br_fdb_fini(void)
index 974feccd28b13e81d2d04cfb1e200422a6960f2a..21bf3a9a03fde363fff8a8e02bc99bac5ad870d1 100644 (file)
@@ -141,7 +141,7 @@ extern void br_dev_setup(struct net_device *dev);
 extern int br_dev_xmit(struct sk_buff *skb, struct net_device *dev);
 
 /* br_fdb.c */
-extern void br_fdb_init(void);
+extern int br_fdb_init(void);
 extern void br_fdb_fini(void);
 extern void br_fdb_flush(struct net_bridge *br);
 extern void br_fdb_changeaddr(struct net_bridge_port *p,