]> err.no Git - linux-2.6/blobdiff - net/mac80211/mesh_pathtbl.c
[ARM] 5117/1: pxafb: fix __devinit/exit annotations
[linux-2.6] / net / mac80211 / mesh_pathtbl.c
index 727aa528c831c28f3b07f943e2f678d98870767b..99c2d360888ef30cc7f0e8637b7aea9af0d474a4 100644 (file)
@@ -164,13 +164,19 @@ int mesh_path_add(u8 *dst, struct net_device *dev)
                err = -ENOMEM;
                goto endadd2;
        }
+       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;
+       }
 
        read_lock(&pathtbl_resize_lock);
        memcpy(new_mpath->dst, dst, ETH_ALEN);
        new_mpath->dev = dev;
        new_mpath->flags = 0;
        skb_queue_head_init(&new_mpath->frame_queue);
-       new_node = kmalloc(sizeof(struct mpath_node), GFP_KERNEL);
        new_node->mpath = new_mpath;
        new_mpath->timer.data = (unsigned long) new_mpath;
        new_mpath->timer.function = mesh_path_timer;
@@ -214,9 +220,10 @@ endadd:
                        return -ENOMEM;
                }
                rcu_assign_pointer(mesh_paths, newtbl);
+               write_unlock(&pathtbl_resize_lock);
+
                synchronize_rcu();
                mesh_table_free(oldtbl, false);
-               write_unlock(&pathtbl_resize_lock);
        }
 endadd2:
        return err;