Skip to content

Commit

Permalink
eCryptfs: fix to use list_for_each_entry_safe() when delete items
Browse files Browse the repository at this point in the history
Since we will be removing items off the list using list_del() we need
to use a safer version of the list_for_each_entry() macro aptly named
list_for_each_entry_safe(). We should use the safe macro if the loop
involves deletions of items.

Signed-off-by: Wei Yongjun <[email protected]>
[tyhicks: Fixed compiler err - missing list_for_each_entry_safe() param]
Signed-off-by: Tyler Hicks <[email protected]>
  • Loading branch information
Wei Yongjun authored and tyhicks committed Dec 18, 2012
1 parent e4bc652 commit 8bbca57
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions fs/ecryptfs/kthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ 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,
kthread_ctl_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);
complete(&req->done);
Expand Down

0 comments on commit 8bbca57

Please sign in to comment.