Skip to content

Commit d55b352

Browse files
arndbamschuma-ntap
authored andcommitted
NFSv4.x: hide array-bounds warning
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: 98b0f80 ("NFSv4.x: Fix a refcount leak in nfs_callback_up_net") Cc: stable@vger.kernel.org # v3.7+ Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
1 parent d75a6a0 commit d55b352

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

fs/nfs/callback.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ static int nfs_callback_up_net(int minorversion, struct svc_serv *serv,
197197
}
198198

199199
ret = -EPROTONOSUPPORT;
200-
if (minorversion == 0)
200+
if (!IS_ENABLED(CONFIG_NFS_V4_1) || minorversion == 0)
201201
ret = nfs4_callback_up_net(serv, net);
202202
else if (xprt->ops->bc_up)
203203
ret = xprt->ops->bc_up(serv, net);

0 commit comments

Comments
 (0)