Skip to content

Commit

Permalink
nfsd: fix race in nfsd_nrthreads()
Browse files Browse the repository at this point in the history
We need the nfsd_mutex before accessing nfsd_serv->sv_nrthreads or we
can't even guarantee nfsd_serv will still be there.

Signed-off-by: Neil Brown <neilb@suse.de>
Acked-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: J. Bruce Fields <bfields@citi.umich.edu>
  • Loading branch information
Neil Brown authored and J. Bruce Fields committed Jun 23, 2008
1 parent abd1ec4 commit c7d106c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions fs/nfsd/nfssvc.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,10 +165,12 @@ int nfsd_vers(int vers, enum vers_op change)

int nfsd_nrthreads(void)
{
if (nfsd_serv == NULL)
return 0;
else
return nfsd_serv->sv_nrthreads;
int rv = 0;
mutex_lock(&nfsd_mutex);
if (nfsd_serv)
rv = nfsd_serv->sv_nrthreads;
mutex_unlock(&nfsd_mutex);
return rv;
}

static void nfsd_last_thread(struct svc_serv *serv)
Expand Down

0 comments on commit c7d106c

Please sign in to comment.