Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4caf86c6 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by John W. Linville
Browse files

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: default avatarPavel Emelyanov <xemul@openvz.org>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 5194ee82
Loading
Loading
Loading
Loading
+13 −2
Original line number Original line Diff line number Diff line
@@ -349,7 +349,7 @@ struct mesh_table *mesh_table_grow(struct mesh_table *tbl)
{
{
	struct mesh_table *newtbl;
	struct mesh_table *newtbl;
	struct hlist_head *oldhash;
	struct hlist_head *oldhash;
	struct hlist_node *p;
	struct hlist_node *p, *q;
	int err = 0;
	int err = 0;
	int i;
	int i;


@@ -373,13 +373,24 @@ struct mesh_table *mesh_table_grow(struct mesh_table *tbl)
	oldhash = tbl->hash_buckets;
	oldhash = tbl->hash_buckets;
	for (i = 0; i <= tbl->hash_mask; i++)
	for (i = 0; i <= tbl->hash_mask; i++)
		hlist_for_each(p, &oldhash[i])
		hlist_for_each(p, &oldhash[i])
			tbl->copy_node(p, newtbl);
			if (tbl->copy_node(p, newtbl) < 0)
				goto errcopy;


endgrow:
endgrow:
	if (err)
	if (err)
		return NULL;
		return NULL;
	else
	else
		return newtbl;
		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;
}
}


/**
/**
+1 −1
Original line number Original line Diff line number Diff line
@@ -109,7 +109,7 @@ struct mesh_table {
	__u32 hash_rnd;			/* Used for hash generation */
	__u32 hash_rnd;			/* Used for hash generation */
	atomic_t entries;		/* Up to MAX_MESH_NEIGHBOURS */
	atomic_t entries;		/* Up to MAX_MESH_NEIGHBOURS */
	void (*free_node) (struct hlist_node *p, bool free_leafs);
	void (*free_node) (struct hlist_node *p, bool free_leafs);
	void (*copy_node) (struct hlist_node *p, struct mesh_table *newtbl);
	int (*copy_node) (struct hlist_node *p, struct mesh_table *newtbl);
	int size_order;
	int size_order;
	int mean_chain_len;
	int mean_chain_len;
};
};
+2 −1
Original line number Original line Diff line number Diff line
@@ -463,7 +463,7 @@ static void mesh_path_node_free(struct hlist_node *p, bool free_leafs)
	kfree(node);
	kfree(node);
}
}


static void mesh_path_node_copy(struct hlist_node *p, struct mesh_table *newtbl)
static int mesh_path_node_copy(struct hlist_node *p, struct mesh_table *newtbl)
{
{
	struct mesh_path *mpath;
	struct mesh_path *mpath;
	struct mpath_node *node, *new_node;
	struct mpath_node *node, *new_node;
@@ -476,6 +476,7 @@ static void mesh_path_node_copy(struct hlist_node *p, struct mesh_table *newtbl)
	hash_idx = mesh_table_hash(mpath->dst, mpath->dev, newtbl);
	hash_idx = mesh_table_hash(mpath->dst, mpath->dev, newtbl);
	hlist_add_head(&new_node->list,
	hlist_add_head(&new_node->list,
			&newtbl->hash_buckets[hash_idx]);
			&newtbl->hash_buckets[hash_idx]);
	return 0;
}
}


int mesh_pathtbl_init(void)
int mesh_pathtbl_init(void)