Akinobu Mita
2007-Apr-18 17:23 UTC
[Bridge] [PATCH] bridge: check kmem_cache_create() error
This patch checks kmem_cache_create() error and aborts loading module on failure. Cc: Stephen Hemminger <shemminger@linux-foundation.org> Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> --- net/bridge/br.c | 7 ++++++- net/bridge/br_fdb.c | 4 +++- net/bridge/br_private.h | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) Index: 2.6-mm/net/bridge/br.c ==================================================================--- 2.6-mm.orig/net/bridge/br.c +++ 2.6-mm/net/bridge/br.c @@ -37,7 +37,9 @@ static int __init br_init(void) return -EADDRINUSE; } - br_fdb_init(); + err = br_fdb_init(); + if (err) + goto err_out0; err = br_netfilter_init(); if (err) @@ -63,7 +65,10 @@ err_out3: err_out2: br_netfilter_fini(); err_out1: + br_fdb_fini(); +err_out0: llc_sap_put(br_stp_sap); + return err; } Index: 2.6-mm/net/bridge/br_fdb.c ==================================================================--- 2.6-mm.orig/net/bridge/br_fdb.c +++ 2.6-mm/net/bridge/br_fdb.c @@ -27,12 +27,14 @@ static struct kmem_cache *br_fdb_cache _ static int fdb_insert(struct net_bridge *br, struct net_bridge_port *source, const unsigned char *addr); -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); + + return br_fdb_cache ? 0 : -ENOMEM; } void __exit br_fdb_fini(void) Index: 2.6-mm/net/bridge/br_private.h ==================================================================--- 2.6-mm.orig/net/bridge/br_private.h +++ 2.6-mm/net/bridge/br_private.h @@ -133,7 +133,7 @@ extern void br_dev_setup(struct net_devi 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_changeaddr(struct net_bridge_port *p, const unsigned char *newaddr);
Stephen Hemminger
2007-Apr-18 17:23 UTC
[Bridge] [PATCH] bridge: check kmem_cache_create() error
On Sat, 7 Apr 2007 18:57:07 +0900 Akinobu Mita <akinobu.mita@gmail.com> wrote:> This patch checks kmem_cache_create() error and aborts loading module > on failure. > > Cc: Stephen Hemminger <shemminger@linux-foundation.org> > Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> >applied for 2.6.22 update bundle
Maybe Matching Threads
- bridge: flush br's address entry in fdb when remove the bridge dev
- [PATCH net] bridge: flush br's address entry in fdb when remove the bridge dev
- [Bridge] [PATCH net-next 1/2] bridge: Add a limit on FDB entries
- [PATCH] xen-blkfront: use bitmap_set() and bitmap_clear()
- [PATCH] xen-blkfront: use bitmap_set() and bitmap_clear()