Skip to content

Commit

Permalink
NFSD: forget_delegations should use list_for_each_entry_safe
Browse files Browse the repository at this point in the history
Otherwise the for loop could try to use a file recently removed from the
file_hashtbl list and oops.

Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
Tested-by: Casey Bodley <cbodley@citi.umich.edu>
Signed-off-by: J. Bruce Fields <bfields@redhat.com>
  • Loading branch information
Bryan Schumaker authored and J. Bruce Fields committed Dec 14, 2011
1 parent 39c4cc0 commit 2d3475c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions fs/nfsd/nfs4state.c
Original file line number Diff line number Diff line change
Expand Up @@ -4505,18 +4505,19 @@ void nfsd_forget_openowners(u64 num)
int nfsd_process_n_delegations(u64 num, void (*deleg_func)(struct nfs4_delegation *))
{
int i, count = 0;
struct nfs4_file *fp;
struct nfs4_delegation *dp, *next;
struct nfs4_file *fp, *fnext;
struct nfs4_delegation *dp, *dnext;

for (i = 0; i < FILE_HASH_SIZE; i++) {
list_for_each_entry(fp, &file_hashtbl[i], fi_hash) {
list_for_each_entry_safe(dp, next, &fp->fi_delegations, dl_perfile) {
list_for_each_entry_safe(fp, fnext, &file_hashtbl[i], fi_hash) {
list_for_each_entry_safe(dp, dnext, &fp->fi_delegations, dl_perfile) {
deleg_func(dp);
if (++count == num)
return count;
}
}
}

return count;
}

Expand Down

0 comments on commit 2d3475c

Please sign in to comment.