From: Frank Sorenson Date: Fri, 8 Jul 2016 21:35:23 +0000 (-0500) Subject: sunrpc: Fix reserved port range calculation X-Git-Tag: v4.14-rc1~2651^2~20 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5d71899a26630654d65e143c63c3c6f12d9aa287;p=platform%2Fkernel%2Flinux-rpi.git 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 Signed-off-by: Trond Myklebust --- diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c index 7e2b2fa..1adda71 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; }