2008-05-07 15:54:42

by Pavel Emelyanov

[permalink] [raw]
Subject: [PATCH 4/7][MAC80211]: Fix sleeping allocation under lock in mesh_path_node_copy.

The mesh_path_node_copy() can be called like this:
mesh_path_add
`- write_lock(&pathtbl_resize_lock); /* ! */
`- mesh_table_grow
`- ->copy_node
`- mesh_path_node_copy

thus, the GFP_KERNEL is not suitable here.

The acceptable fix, I suppose, is make this allocation GPF_ATOMIC -
the mpath_node being allocated is 4 pointers, i.e. this allocation
is small enough to survive even under a moderate memory pressure.

Signed-off-by: Pavel Emelyanov <[email protected]>

---
net/mac80211/mesh_pathtbl.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/net/mac80211/mesh_pathtbl.c b/net/mac80211/mesh_pathtbl.c
index fe1ceee..1154398 100644
--- a/net/mac80211/mesh_pathtbl.c
+++ b/net/mac80211/mesh_pathtbl.c
@@ -469,7 +469,7 @@ static int mesh_path_node_copy(struct hlist_node *p, struct mesh_table *newtbl)
struct mpath_node *node, *new_node;
u32 hash_idx;

- new_node = kmalloc(sizeof(struct mpath_node), GFP_KERNEL);
+ new_node = kmalloc(sizeof(struct mpath_node), GFP_ATOMIC);
if (new_node == NULL)
return -ENOMEM;

--
1.5.3.4