From 4caf86c6928cfaca270327bc944f901c2e2a8f50 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Wed, 7 May 2008 19:47:01 +0400 Subject: mac80211: Prepare mesh_table_grow to failing copy_node callback. The mesh_path_node_copy() performs kmalloc() and thus - may fail (well, it does not now, but I'm fixing this right now). Its caller - the mesh_table_grow() - isn't prepared for such a trick yet. This preparation is just flush the new hash and make copy_node() return an int value. Signed-off-by: Pavel Emelyanov Signed-off-by: John W. Linville --- net/mac80211/mesh.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'net/mac80211/mesh.c') diff --git a/net/mac80211/mesh.c b/net/mac80211/mesh.c index 697ef67f96b..ca81d0065eb 100644 --- a/net/mac80211/mesh.c +++ b/net/mac80211/mesh.c @@ -349,7 +349,7 @@ struct mesh_table *mesh_table_grow(struct mesh_table *tbl) { struct mesh_table *newtbl; struct hlist_head *oldhash; - struct hlist_node *p; + struct hlist_node *p, *q; int err = 0; int i; @@ -373,13 +373,24 @@ struct mesh_table *mesh_table_grow(struct mesh_table *tbl) oldhash = tbl->hash_buckets; for (i = 0; i <= tbl->hash_mask; i++) hlist_for_each(p, &oldhash[i]) - tbl->copy_node(p, newtbl); + if (tbl->copy_node(p, newtbl) < 0) + goto errcopy; endgrow: if (err) return NULL; else return newtbl; + +errcopy: + for (i = 0; i <= newtbl->hash_mask; i++) { + hlist_for_each_safe(p, q, &newtbl->hash_buckets[i]) + tbl->free_node(p, 0); + } + kfree(newtbl->hash_buckets); + kfree(newtbl->hashwlock); + kfree(newtbl); + return NULL; } /** -- cgit v1.2.3