From: Arnd Bergmann Date: Tue, 22 Nov 2016 20:50:52 +0000 (+0100) Subject: NFSv4.x: hide array-bounds warning X-Git-Tag: Ubuntu-snapdragon-4.4.0-1050.54~1106 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=6ba167ca2b320dc9c9ca5ca0470034c276fe7677;p=mirror_ubuntu-artful-kernel.git NFSv4.x: hide array-bounds warning BugLink: http://bugs.launchpad.net/bugs/1650601 commit d55b352b01bc78fbc3d1bb650140668b87e58bf9 upstream. A correct bugfix introduced a harmless warning that shows up with gcc-7: fs/nfs/callback.c: In function 'nfs_callback_up': fs/nfs/callback.c:214:14: error: array subscript is outside array bounds [-Werror=array-bounds] What happens here is that the 'minorversion == 0' check tells the compiler that we assume minorversion can be something other than 0, but when CONFIG_NFS_V4_1 is disabled that would be invalid and result in an out-of-bounds access. The added check for IS_ENABLED(CONFIG_NFS_V4_1) tells gcc that this really can't happen, which makes the code slightly smaller and also avoids the warning. The bugfix that introduced the warning is marked for stable backports, we want this one backported to the same releases. Fixes: 98b0f80c2396 ("NFSv4.x: Fix a refcount leak in nfs_callback_up_net") Signed-off-by: Arnd Bergmann Signed-off-by: Anna Schumaker Signed-off-by: Greg Kroah-Hartman Signed-off-by: Tim Gardner Signed-off-by: Luis Henriques --- diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c index 52a28311e2a4..48efe62e1302 100644 --- a/fs/nfs/callback.c +++ b/fs/nfs/callback.c @@ -261,7 +261,7 @@ static int nfs_callback_up_net(int minorversion, struct svc_serv *serv, } ret = -EPROTONOSUPPORT; - if (minorversion == 0) + if (!IS_ENABLED(CONFIG_NFS_V4_1) || minorversion == 0) ret = nfs4_callback_up_net(serv, net); else if (xprt->ops->bc_up) ret = xprt->ops->bc_up(serv, net);