Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5d71899a authored by Frank Sorenson's avatar Frank Sorenson Committed by Trond Myklebust
Browse files

sunrpc: Fix reserved port range calculation



The range calculation for choosing the random reserved port will panic
with divide-by-zero when min_resvport == max_resvport, a range of one
port, not zero.

Fix the reserved port range calculation by adding one to the difference.

Signed-off-by: default avatarFrank Sorenson <sorenson@redhat.com>
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@primarydata.com>
parent 34ae685c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1714,7 +1714,7 @@ static void xs_udp_timer(struct rpc_xprt *xprt, struct rpc_task *task)

static unsigned short xs_get_random_port(void)
{
	unsigned short range = xprt_max_resvport - xprt_min_resvport;
	unsigned short range = xprt_max_resvport - xprt_min_resvport + 1;
	unsigned short rand = (unsigned short) prandom_u32() % range;
	return rand + xprt_min_resvport;
}