Commit 87a596e0b8bc344bd6bfebe83b56d11fb79ee23a

Authored by Akinobu Mita
Committed by David S. Miller
1 parent ffe1d49cc3

bridge: check kmem_cache_create() error

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>

Showing 3 changed files with 9 additions and 3 deletions Side-by-side Diff

... ... @@ -37,7 +37,9 @@
37 37 return -EADDRINUSE;
38 38 }
39 39  
40   - br_fdb_init();
  40 + err = br_fdb_init();
  41 + if (err)
  42 + goto err_out1;
41 43  
42 44 err = br_netfilter_init();
43 45 if (err)
... ... @@ -31,13 +31,17 @@
31 31  
32 32 static u32 fdb_salt __read_mostly;
33 33  
34   -void __init br_fdb_init(void)
  34 +int __init br_fdb_init(void)
35 35 {
36 36 br_fdb_cache = kmem_cache_create("bridge_fdb_cache",
37 37 sizeof(struct net_bridge_fdb_entry),
38 38 0,
39 39 SLAB_HWCACHE_ALIGN, NULL, NULL);
  40 + if (!br_fdb_cache)
  41 + return -ENOMEM;
  42 +
40 43 get_random_bytes(&fdb_salt, sizeof(fdb_salt));
  44 + return 0;
41 45 }
42 46  
43 47 void __exit br_fdb_fini(void)
net/bridge/br_private.h
... ... @@ -141,7 +141,7 @@
141 141 extern int br_dev_xmit(struct sk_buff *skb, struct net_device *dev);
142 142  
143 143 /* br_fdb.c */
144   -extern void br_fdb_init(void);
  144 +extern int br_fdb_init(void);
145 145 extern void br_fdb_fini(void);
146 146 extern void br_fdb_flush(struct net_bridge *br);
147 147 extern void br_fdb_changeaddr(struct net_bridge_port *p,