Skip to content

Commit 1d498df

Browse files
neilbrownAnna Schumaker
authored and
Anna Schumaker
committed
sunrpc: fix prog selection loop in svc_process_common
If the rq_prog is not in the list of programs, then we use the last program in the list and we don't get the expected rpc_prog_unavail error as the subsequent tests on 'progp' being NULL are ineffective. We should only assign progp when we find the right program, and we should initialize it to NULL Reported-by: Dan Carpenter <[email protected]> Fixes: 86ab08b ("SUNRPC: replace program list with program array") Signed-off-by: NeilBrown <[email protected]> Acked-by: Chuck Lever <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 37578c6 commit 1d498df

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

net/sunrpc/svc.c

+4-7
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ static int
13211321
svc_process_common(struct svc_rqst *rqstp)
13221322
{
13231323
struct xdr_stream *xdr = &rqstp->rq_res_stream;
1324-
struct svc_program *progp;
1324+
struct svc_program *progp = NULL;
13251325
const struct svc_procedure *procp = NULL;
13261326
struct svc_serv *serv = rqstp->rq_server;
13271327
struct svc_process_info process;
@@ -1351,12 +1351,9 @@ svc_process_common(struct svc_rqst *rqstp)
13511351
rqstp->rq_vers = be32_to_cpup(p++);
13521352
rqstp->rq_proc = be32_to_cpup(p);
13531353

1354-
for (pr = 0; pr < serv->sv_nprogs; pr++) {
1355-
progp = &serv->sv_programs[pr];
1356-
1357-
if (rqstp->rq_prog == progp->pg_prog)
1358-
break;
1359-
}
1354+
for (pr = 0; pr < serv->sv_nprogs; pr++)
1355+
if (rqstp->rq_prog == serv->sv_programs[pr].pg_prog)
1356+
progp = &serv->sv_programs[pr];
13601357

13611358
/*
13621359
* Decode auth data, and add verifier to reply buffer.

0 commit comments

Comments
 (0)