RE: [PATCH] eCryptfs: use list_for_each_safe() when the loop involves delete items

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sorry for the bad patch title and description, please ignore this patch,
And I will send a update version.

Thanks

-----Original Message-----
From: Wei Yongjun [mailto:weiyj.lk@xxxxxxxxx] 
Sent: 2012年8月21日 8:38
To: tyhicks@xxxxxxxxxxxxx; dustin.kirkland@xxxxxxxxxxx
Cc: Yongjun Wei (RD-CN); ecryptfs@xxxxxxxxxxxxxxx
Subject: [PATCH] eCryptfs: use list_for_each_safe() when the loop involves delete items

From: Wei Yongjun <yongjun_wei@xxxxxxxxxxxxxxxxx>


From: Wei Yongjun <yongjun_wei@xxxxxxxxxxxxxxxxx>

Since we will be removing items off the list using list_del() we need to use a safer version of the list_for_each() macro aptly named list_for_each_safe(). Note that we MUST use this macro if the loop involves deletions of items (or moving items from one list to another).

Signed-off-by: Wei Yongjun <yongjun_wei@xxxxxxxxxxxxxxxxx>
---
 fs/ecryptfs/kthread.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ecryptfs/kthread.c b/fs/ecryptfs/kthread.c index 809e67d..072ceee 100644
--- a/fs/ecryptfs/kthread.c
+++ b/fs/ecryptfs/kthread.c
@@ -102,11 +102,11 @@ int __init ecryptfs_init_kthread(void)
 
 void ecryptfs_destroy_kthread(void)
 {
-	struct ecryptfs_open_req *req;
+	struct ecryptfs_open_req *req, *tmp;
 
 	mutex_lock(&ecryptfs_kthread_ctl.mux);
 	ecryptfs_kthread_ctl.flags |= ECRYPTFS_KTHREAD_ZOMBIE;
-	list_for_each_entry(req, &ecryptfs_kthread_ctl.req_list,
+	list_for_each_entry_safe(req, tmp, &ecryptfs_kthread_ctl.req_list,
 			    kthread_ctl_list) {
 		list_del(&req->kthread_ctl_list);
 		*req->lower_file = ERR_PTR(-EIO);



TREND MICRO EMAIL NOTICE
The information contained in this email and any attachments is confidential and may be subject to copyright or other intellectual property protection. If you are not the intended recipient, you are not authorized to use or disclose this information, and we request that you notify us by reply mail or telephone and delete the original message from your mail system.?韬{.n?????%??檩??w?{.n???缉蝶?{ay????j?f"??????_璁(????"??m???G??⒏??璀?x??



[Index of Archives]     [Linux Crypto]     [Device Mapper Crypto]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux