[sheepdog] [PATCH] sheep: fix clear_client crash
Yunkai Zhang
yunkai.me at gmail.com
Mon Jul 9 14:50:18 CEST 2012
From: Yunkai Zhang <qiushu.zyk at taobao.com>
We should use list_for_each_entry_safe instead of list_for_each_entry
to loop when we need to delete node in it.
Signed-off-by: Yunkai Zhang <qiushu.zyk at taobao.com>
---
sheep/sdnet.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sheep/sdnet.c b/sheep/sdnet.c
index 3a6572e..a2a7bc1 100644
--- a/sheep/sdnet.c
+++ b/sheep/sdnet.c
@@ -676,7 +676,7 @@ static void destroy_client(struct client_info *ci)
static void clear_client(struct client_info *ci)
{
- struct request *req;
+ struct request *req, *t;
if (ci->rx_req) {
free_request(ci->rx_req);
@@ -688,7 +688,7 @@ static void clear_client(struct client_info *ci)
ci->tx_req = NULL;
}
- list_for_each_entry(req, &ci->done_reqs, request_list) {
+ list_for_each_entry_safe(req, t, &ci->done_reqs, request_list) {
list_del(&req->request_list);
free_request(req);
}
--
1.7.10.4
More information about the sheepdog
mailing list