summaryrefslogtreecommitdiffstats
path: root/net/sunrpc/xprtsock.c
diff options
context:
space:
mode:
authorFrank Sorenson <sorenson@redhat.com>2016-07-08 16:35:23 -0500
committerTrond Myklebust <trond.myklebust@primarydata.com>2016-07-19 16:23:26 -0400
commit5d71899a26630654d65e143c63c3c6f12d9aa287 (patch)
treec33b7e75e2569c4c4ea7af2881d678cbfa379e06 /net/sunrpc/xprtsock.c
parent34ae685cb3ac965c0c733c866412f3b66ddd64e7 (diff)
downloadblackbird-op-linux-5d71899a26630654d65e143c63c3c6f12d9aa287.tar.gz
blackbird-op-linux-5d71899a26630654d65e143c63c3c6f12d9aa287.zip
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: Frank Sorenson <sorenson@redhat.com> Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
Diffstat (limited to 'net/sunrpc/xprtsock.c')
-rw-r--r--net/sunrpc/xprtsock.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 7e2b2fa189c3..1adda71f4e3a 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -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;
}
OpenPOWER on IntegriCloud