{
struct mesh_table *newtbl;
struct hlist_head *oldhash;
- struct hlist_node *p;
+ struct hlist_node *p, *q;
int err = 0;
int i;
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;
}
/**