]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit
NFSv4.x: hide array-bounds warning
authorArnd Bergmann <arnd@arndb.de>
Tue, 22 Nov 2016 20:50:52 +0000 (21:50 +0100)
committerLuis Henriques <luis.henriques@canonical.com>
Tue, 10 Jan 2017 17:41:53 +0000 (17:41 +0000)
commit6ba167ca2b320dc9c9ca5ca0470034c276fe7677
treed819bbf21b598d42833ace815703fb73922845ac
parent62fe4ff99258504bd4c2bd95b848bab5065e4a81
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 <arnd@arndb.de>
Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
fs/nfs/callback.c