From patchwork Tue Nov 22 20:50:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 9442153 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 22E8660235 for ; Tue, 22 Nov 2016 20:51:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 149CD1FE83 for ; Tue, 22 Nov 2016 20:51:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 07FDB1FFAE; Tue, 22 Nov 2016 20:51:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38CFD1FEC1 for ; Tue, 22 Nov 2016 20:51:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756856AbcKVUvX (ORCPT ); Tue, 22 Nov 2016 15:51:23 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:59912 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756269AbcKVUvW (ORCPT ); Tue, 22 Nov 2016 15:51:22 -0500 Received: from wuerfel.lan ([78.43.21.235]) by mrelayeu.kundenserver.de (mreue004 [212.227.15.129]) with ESMTPA (Nemesis) id 0LyQ8Q-1cmFDW1y8U-015t9i; Tue, 22 Nov 2016 21:51:00 +0100 From: Arnd Bergmann To: Trond Myklebust Cc: Arnd Bergmann , Anna Schumaker , linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] NFSv4.x: hide array-bounds warning Date: Tue, 22 Nov 2016 21:50:52 +0100 Message-Id: <20161122205059.754211-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K0:fKNA+tRgpyJ0gZezgh6FDWIqDpnmYQVo7UPXZUTx4y2yJoz59l5 ybIuBYyR0eOTSM0Yxq7WkIf38KKNB/dX8LgQVhV93SOvStzmyVzUTHUl36Ext0WBdwembQV 40QYVpOBoHXRugPOUFAHGfhPxjuLBRUH/BVZEQqPKkeQ2dJDL0KlSGjKEYJvy9gXLWDOgog zoSWXtQ5gp9Qdmlebft3w== X-UI-Out-Filterresults: notjunk:1; V01:K0:6SQZRDCiJyA=:Tc5fdKfHZkdACSEY0KXXQS 77ORCgP5Ifn56omHmSJkZ23/+GvY13xMm3dI4T7x/shbbPs973joBPO1OiYCPfOmsDdkWq9i/ 9cxALdD66qb/8Zi3e6Av63arPjklnNf/o+BcRYYTnQLhx4RXu6b5in+RN2b+NE+voKAt3s/zZ 4j426S8NO+X1GSGCQNPk8+aeRHzUYSpY8WNQwD5tKyKMIHXYUYfZTkJNrsd6BFSZkb/nuln2G +1BezdLqNXctx+5k9gC49ApTGc5ftxOBTfYxzKtV1ub/JWyEqHo5j0NUHu0gpeD2ZOAOc611k Ag5D8Gu384vXcCVWXBiufydBNwzaeKPk2Y4h/l53hKdJT2bA+n1rSQ8hlC3X0CM07QJnGdZ1c UbThv3G2HH6wxvjZXBdBdwb6mPcApQIOHdBajv7UTC3fccs9CLZBLUZCPKg+ZQuV7bZOw8StB II1bEiHeAC8ewKjQo4AD+s4DrXmp/ZeagX32X/vLo3wuZaw3dqFChrGiZ4FyvKL9p3CmivZ5q 9gWo+CURi9RG7V1/YM57kPNyp8Y9muF3+gvkJal33y718OOH/OpxcGfV5au7MpKVKu0b+ZIre 9Ar+2pUvgatxuPV6grWampHrz7ry21ihFKLXktOs+kxmhrofJvCK8bWtUjlt37U8UplyQ1MI4 k6z2mWMkp2iMG1a/DZp8EMuCVEDdI5CaLc7EWZW/k63NFSGs71VTeLLaFLbxQJjNnEEA= Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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") Cc: stable@vger.kernel.org # v3.7+ Signed-off-by: Arnd Bergmann --- fs/nfs/callback.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfs/callback.c b/fs/nfs/callback.c index 532d8e242d4d..484bebc20bca 100644 --- a/fs/nfs/callback.c +++ b/fs/nfs/callback.c @@ -197,7 +197,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);