Skip to content

Commit 8e948c3

Browse files
jtlaytonchucklever
authored andcommitted
nfsd: fix oops when reading pool_stats before server is started
Sourbh reported an oops that is triggerable by trying to read the pool_stats procfile before nfsd had been started. Move the check for a NULL serv in svc_pool_stats_start above the mutex acquisition, and fix the stop routine not to unlock the mutex if there is no serv yet. Fixes: 7b207cc ("svc: don't hold reference for poolstats, only mutex.") Reported-by: Sourabh Jain <sourabhjain@linux.ibm.com> Signed-off-by: Jeff Layton <jlayton@kernel.org> Tested-by: Sourabh Jain <sourabhjain@linux.ibm.com> Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 4a77c3d commit 8e948c3

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

net/sunrpc/svc_xprt.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,12 +1421,13 @@ static void *svc_pool_stats_start(struct seq_file *m, loff_t *pos)
14211421

14221422
dprintk("svc_pool_stats_start, *pidx=%u\n", pidx);
14231423

1424+
if (!si->serv)
1425+
return NULL;
1426+
14241427
mutex_lock(si->mutex);
14251428

14261429
if (!pidx)
14271430
return SEQ_START_TOKEN;
1428-
if (!si->serv)
1429-
return NULL;
14301431
return pidx > si->serv->sv_nrpools ? NULL
14311432
: &si->serv->sv_pools[pidx - 1];
14321433
}
@@ -1458,7 +1459,8 @@ static void svc_pool_stats_stop(struct seq_file *m, void *p)
14581459
{
14591460
struct svc_info *si = m->private;
14601461

1461-
mutex_unlock(si->mutex);
1462+
if (si->serv)
1463+
mutex_unlock(si->mutex);
14621464
}
14631465

14641466
static int svc_pool_stats_show(struct seq_file *m, void *p)

0 commit comments

Comments
 (0)