From patchwork Fri Oct 9 14:13:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 7362101 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E3645BEEA4 for ; Fri, 9 Oct 2015 14:14:28 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6D5D520735 for ; Fri, 9 Oct 2015 14:14:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 64CD0207E6 for ; Fri, 9 Oct 2015 14:14:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754859AbbJIOOV (ORCPT ); Fri, 9 Oct 2015 10:14:21 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:51409 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752831AbbJIOOU (ORCPT ); Fri, 9 Oct 2015 10:14:20 -0400 Received: from wuerfel.localnet ([149.172.15.242]) by mrelayeu.kundenserver.de (mreue101) with ESMTPSA (Nemesis) id 0MYNd3-1a6GBG1tuD-00V52u; Fri, 09 Oct 2015 16:13:47 +0200 From: Arnd Bergmann To: Trond Myklebust , linux-nfs@vger.kernel.org Cc: Anna Schumaker , "J. Bruce Fields" , Jeff Layton , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH] sunrpc: avoid warning in gss_key_timeout Date: Fri, 09 Oct 2015 16:13:45 +0200 Message-ID: <6995148.OQIKcAcqHW@wuerfel> User-Agent: KMail/4.11.5 (Linux/3.16.0-10-generic; KDE/4.11.5; x86_64; ; ) MIME-Version: 1.0 X-Provags-ID: V03:K0:qopTzfTIB+1L+CcsJVW8siBeGA2PuJHnSSZIlrx7fmaZnl3nswq xvZG/kMgeLxqshEHFBfINrL/jpxXUTU9GzlHmpAGTzlf8c0TQBtIMY0GKIBTLwxPw3KtEFb oTN/AssxPfwcsYvMuShNM7AMz4BS6PH12jwbLtJfWxTIthhCrUdyipVE7+cxd01I+VJr0gT 6Phtd7eRqNzSMj5+TbKBw== X-UI-Out-Filterresults: notjunk:1; V01:K0:A5PWPVHoBe0=:1JlulMuuJUmYl53fS5qtKT R9qEnkOTUnh7TB0b6VEehLb7OJkPMxbpU0AQJrkUOTnIyiS+5ze8yjs+Aot+VFEuY5p+h/cnH Lf7o0nDyQ5gcF9zcMfFHvxc+nEgTveL5R4sIbOSP3WLKTHNoW8WiIBMvlhGec0HexKBvZjo+V Y0Ybw/cK1CardurQVAkILbLwcZGMnTsYkutGs6AuY8r6XPNn+g9qxTojFAre/Fdnr0fVa1GRJ d3tQII0pJ/0zCi/Ss0Y7ruw+vqxHagyihhtc8B2L1Jc/u7mCPP7LK0aF6GPsylKqXs01jebw3 53qqiA3XVvc1j/oY156QVC6Nzyga2LmgRjqg1iouOoI7FhJixuOShggC7OCzSKEz+aTECB6x9 uJyL1a7XAl9eoz90yB7x1QbXKoo0GVBeoGUF90ydK0zNdzoY/0pgVv+n0+yfEcjAHz3OgxMvS iFMIeUKfwB2hUwvnyThSa6yiQkd7lcL13gLiBzArTVi6A6T8w4cTrNpTuu6/HzsT0WyfimKoe UjzhAAPkeACMiAyPRnJHF3g5vnrs4Wk4rHwBTHltackUY2HbUVi2cjJZQjnwqoTRPZyxp6Erg buFbM68XmtusbAZqqabQ9sB7LaKaUtQazb91voxRDJ6/4GNmQj1CiKsvbJ1CcBCduFtdqTk6M 33mNWLvwmJHOR1vQipzDq8z5K6adRIEJ37cNwx+9T1hBoXCsjwhhBHuUDXgbvKD83eiO5jepM PiooweydVVOIb77y Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The gss_key_timeout() function causes a harmless warning in some configurations, e.g. ARM imx_v6_v7_defconfig with gcc-5.2, if the compiler cannot figure out the state of the 'expire' variable across an rcu_read_unlock(): net/sunrpc/auth_gss/auth_gss.c: In function 'gss_key_timeout': net/sunrpc/auth_gss/auth_gss.c:1422:211: warning: 'expire' may be used uninitialized in this function [-Wmaybe-uninitialized] To avoid this warning without adding a bogus initialization, this rewrites the function so the comparison is done inside of the critical section. As a side-effect, it also becomes slightly easier to understand because the implementation now more closely resembles the comment above it. Signed-off-by: Arnd Bergmann Fixes: c5e6aecd034e7 ("sunrpc: fix RCU handling of gc_ctx field") --- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c index dace13d7638e..799e65b944b9 100644 --- a/net/sunrpc/auth_gss/auth_gss.c +++ b/net/sunrpc/auth_gss/auth_gss.c @@ -1411,17 +1411,16 @@ gss_key_timeout(struct rpc_cred *rc) { struct gss_cred *gss_cred = container_of(rc, struct gss_cred, gc_base); struct gss_cl_ctx *ctx; - unsigned long now = jiffies; - unsigned long expire; + unsigned long timeout = jiffies + (gss_key_expire_timeo * HZ); + int ret = 0; rcu_read_lock(); ctx = rcu_dereference(gss_cred->gc_ctx); - if (ctx) - expire = ctx->gc_expiry - (gss_key_expire_timeo * HZ); + if (!ctx || time_after(timeout, ctx->gc_expiry)) + ret = -EACCES; rcu_read_unlock(); - if (!ctx || time_after(now, expire)) - return -EACCES; - return 0; + + return ret; } static int