Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 102726
b: refs/heads/master
c: 402d775
h: refs/heads/master
v: v3
  • Loading branch information
Pavel Emelyanov authored and John W. Linville committed May 22, 2008
1 parent 8344239 commit d16c79f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b679aeb304e3070626750c15e043a40da0e942fc
refs/heads/master: 402d7752ed253369b7ab037e2d778e52d59c19ed
42 changes: 20 additions & 22 deletions trunk/net/mac80211/mesh_pathtbl.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,19 +158,14 @@ int mesh_path_add(u8 *dst, struct net_device *dev)
if (atomic_add_unless(&sdata->u.sta.mpaths, 1, MESH_MAX_MPATHS) == 0)
return -ENOSPC;

err = -ENOMEM;
new_mpath = kzalloc(sizeof(struct mesh_path), GFP_KERNEL);
if (!new_mpath) {
atomic_dec(&sdata->u.sta.mpaths);
err = -ENOMEM;
goto endadd2;
}
if (!new_mpath)
goto err_path_alloc;

new_node = kmalloc(sizeof(struct mpath_node), GFP_KERNEL);
if (!new_node) {
kfree(new_mpath);
atomic_dec(&sdata->u.sta.mpaths);
err = -ENOMEM;
goto endadd2;
}
if (!new_node)
goto err_node_alloc;

read_lock(&pathtbl_resize_lock);
memcpy(new_mpath->dst, dst, ETH_ALEN);
Expand All @@ -189,27 +184,21 @@ int mesh_path_add(u8 *dst, struct net_device *dev)

spin_lock(&mesh_paths->hashwlock[hash_idx]);

err = -EEXIST;
hlist_for_each_entry(node, n, bucket, list) {
mpath = node->mpath;
if (mpath->dev == dev && memcmp(dst, mpath->dst, ETH_ALEN)
== 0) {
err = -EEXIST;
atomic_dec(&sdata->u.sta.mpaths);
kfree(new_node);
kfree(new_mpath);
goto endadd;
}
if (mpath->dev == dev && memcmp(dst, mpath->dst, ETH_ALEN) == 0)
goto err_exists;
}

hlist_add_head_rcu(&new_node->list, bucket);
if (atomic_inc_return(&mesh_paths->entries) >=
mesh_paths->mean_chain_len * (mesh_paths->hash_mask + 1))
grow = 1;

endadd:
spin_unlock(&mesh_paths->hashwlock[hash_idx]);
read_unlock(&pathtbl_resize_lock);
if (!err && grow) {
if (grow) {
struct mesh_table *oldtbl, *newtbl;

write_lock(&pathtbl_resize_lock);
Expand All @@ -225,7 +214,16 @@ int mesh_path_add(u8 *dst, struct net_device *dev)
synchronize_rcu();
mesh_table_free(oldtbl, false);
}
endadd2:
return 0;

err_exists:
spin_unlock(&mesh_paths->hashwlock[hash_idx]);
read_unlock(&pathtbl_resize_lock);
kfree(new_node);
err_node_alloc:
kfree(new_mpath);
err_path_alloc:
atomic_dec(&sdata->u.sta.mpaths);
return err;
}

Expand Down

0 comments on commit d16c79f

Please sign in to comment.