From patchwork Fri Jun 8 05:03:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Chancellor X-Patchwork-Id: 137911 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp413491lji; Thu, 7 Jun 2018 22:03:09 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIMkt7Wb9dhPzYta1Z6UbkYp9+u1Bi+jgScL/lBsFBrALIfREorFrhGrT3zn0ZUGuRTviUu X-Received: by 2002:a17:902:8b86:: with SMTP id ay6-v6mr4867797plb.295.1528434189587; Thu, 07 Jun 2018 22:03:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528434189; cv=none; d=google.com; s=arc-20160816; b=m0A5g2uRO7BZllX7qzD5ky5WkNRb5OwkMNCrCs9G+Yxpu0kxMLrrOOhbXJWtgPeRg/ 4tJSHp9WE2sEetabvPGCCK93VGvJGfuUacuiT15mns8GSmQvGJmJi61vHOlo5W625c2P Ic4MEV2y6FUaEBMD3ebCh+0dy6fsF77Bg6bBFH3Fh5Vom5GSukSf2AENSe8IzoqnXkFM wEIwCVvBT1m1pwH5/lJJM3TtXSJiiwRZ3846Hd+u3TI3S5Ou2XLWOFzA9PwGgLH1HenL yI+xMt6xc88SXijnGROqoChzVdXKMJ55WeZEUtVHhkWGlfmDjgECUvmBfr8kQ9ZibKcG CD+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=jw1bVpAYmLBd1wZcViLuWHjTDB7gYIn/sKyk4d6FfOo=; b=hKp7uoKB/kWCASMVBkgFuqbt+z+Mthvf2ylsimTL8OyWGGNoEtA7hGqgEenEtx1U+t sWT11LrNtHEc9/h79SECgyFhfLEb/SKrKk9nO30mQezqc/t73rfZ472L9wHuBzV6XNwl z3GEhDJb1gq45Gkb77H0ey6YXNfBGavSe6jxqoQ51cAW3SchTej2S2aYPAMU4Q5KnD1/ +6/jXslP5x0HzqztUsdnJNuaR2hpo3DyfYCff1FF4RTZ/J/tQ7zLLfghFXYPiB6Yyjfm zOGWKnSVXn0ctlJ0FL2ibiHYnmXojKZqEUFYW1oqDMqSYrwxkw0zpYkNgmu0XVsUjPYg dYcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=V5wHKBeU; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p8-v6si16511079pgd.96.2018.06.07.22.03.09; Thu, 07 Jun 2018 22:03:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=V5wHKBeU; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750977AbeFHFDI (ORCPT + 13 others); Fri, 8 Jun 2018 01:03:08 -0400 Received: from mail-wm0-f68.google.com ([74.125.82.68]:55297 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750965AbeFHFDH (ORCPT ); Fri, 8 Jun 2018 01:03:07 -0400 Received: by mail-wm0-f68.google.com with SMTP id v16-v6so977382wmh.5 for ; Thu, 07 Jun 2018 22:03:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=jw1bVpAYmLBd1wZcViLuWHjTDB7gYIn/sKyk4d6FfOo=; b=V5wHKBeUL2RcrwalJLUKr0GCnCINP2EDyqun5SFzZaZOHdyqpFxLV8f4YpgzZnabWe a2ZQTr36jQ8Gf6x7hHTbEhKU5Q1WLcPnt7pP39L1xBHQt2X/LU6jg8TGwNw90v808Hya R75LFRYj7DV6Bpo33LyRxJkFZT/f4s2ZOxX5zDgpYageYSNH7iCfKCqSeMDkeY/rf5J6 nJI2xI7F220W2p98ZNZXc3qKHoVqrGdDdQqUpj6mV49kuPMG+hYNFsC3ujx5OMOnQ9OJ xrWJDReqWjUTdDaGDLwYzmOeAlZt1eATqQ4/ZRENaauYx50IfzypQbwNLYEOZm85L+Nr 2uEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=jw1bVpAYmLBd1wZcViLuWHjTDB7gYIn/sKyk4d6FfOo=; b=jleu+Da2BYnGjFZi33/sMvD/HURhw2UCz932RdJ230gU70aisCktm5JYLueRF3EBE4 iBtCHc4COQfpOt/W7KLWImM3YFA4wTJgM45YN59WL9WrMOAkRselHwigb2gB6BhJ6n6M jkpgz3vUqnfLdLxmWB0UgDn9ZVw5eHGC4oRBr3IMk2mZYFwCg08lmJzFrQi6j1u1UloQ 6ivPp4dTPBLyNA5uSfUFNwzezEbv1u/e68KxUCGx5JZ/+uoFp8jlkgPpqHU0fHpt1BQz xnrfPUUoLVQBy4pQfEGNHaKDH1uF2U2LMu3vpXZgFb0RKTw+slclUWhuYGo+Lcca6YKf GO2w== X-Gm-Message-State: APt69E1XQ/mX4eUoD305bPQ0xNXeOVqwX8nEdpf6Hl9W07O6XQQZVIJL 5oiN+Bv3ecle/E+EuL8jRuU= X-Received: by 2002:a1c:7192:: with SMTP id d18-v6mr364063wmi.115.1528434186216; Thu, 07 Jun 2018 22:03:06 -0700 (PDT) Received: from flashbox.your-server.de ([2a01:4f8:10b:24a5::2]) by smtp.gmail.com with ESMTPSA id n18-v6sm37830726wrj.58.2018.06.07.22.03.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 22:03:05 -0700 (PDT) From: Nathan Chancellor To: Greg Kroah-Hartman , stable@vger.kernel.org Cc: Arnd Bergmann , Mike Snitzer , Nathan Chancellor Subject: [PATCH] dm bufio: avoid false-positive Wmaybe-uninitialized warning Date: Thu, 7 Jun 2018 22:03:44 -0700 Message-Id: <20180608050344.27572-1-natechancellor@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Arnd Bergmann commit 590347e4000356f55eb10b03ced2686bd74dab40 upstream. gcc-6.3 and earlier show a new warning after a seemingly unrelated change to the arm64 PAGE_KERNEL definition: In file included from drivers/md/dm-bufio.c:14:0: drivers/md/dm-bufio.c: In function 'alloc_buffer': include/linux/sched/mm.h:182:56: warning: 'noio_flag' may be used uninitialized in this function [-Wmaybe-uninitialized] current->flags = (current->flags & ~PF_MEMALLOC_NOIO) | flags; ^ The same warning happened earlier on linux-3.18 for MIPS and I did a workaround for that, but now it's come back. gcc-7 and newer are apparently smart enough to figure this out, and other architectures don't show it, so the best I could come up with is to rework the caller slightly in a way that makes it obvious enough to all arm64 compilers what is happening here. Fixes: 41acec624087 ("arm64: kpti: Make use of nG dependent on arm64_kernel_unmapped_at_el0()") Link: https://patchwork.kernel.org/patch/9692829/ Cc: stable@vger.kernel.org Signed-off-by: Arnd Bergmann [snitzer: moved declarations inside conditional, altered vmalloc return] Signed-off-by: Mike Snitzer [nc: Backport to 4.9, adjust context for lack of 19809c2da28a] Signed-off-by: Nathan Chancellor --- drivers/md/dm-bufio.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) -- 2.17.1 diff --git a/drivers/md/dm-bufio.c b/drivers/md/dm-bufio.c index 3ec647e8b9c6..35fd57fdeba9 100644 --- a/drivers/md/dm-bufio.c +++ b/drivers/md/dm-bufio.c @@ -373,9 +373,6 @@ static void __cache_size_refresh(void) static void *alloc_buffer_data(struct dm_bufio_client *c, gfp_t gfp_mask, enum data_mode *data_mode) { - unsigned noio_flag; - void *ptr; - if (c->block_size <= DM_BUFIO_BLOCK_SIZE_SLAB_LIMIT) { *data_mode = DATA_MODE_SLAB; return kmem_cache_alloc(DM_BUFIO_CACHE(c), gfp_mask); @@ -399,16 +396,16 @@ static void *alloc_buffer_data(struct dm_bufio_client *c, gfp_t gfp_mask, * all allocations done by this process (including pagetables) are done * as if GFP_NOIO was specified. */ + if (gfp_mask & __GFP_NORETRY) { + unsigned noio_flag = memalloc_noio_save(); + void *ptr = __vmalloc(c->block_size, gfp_mask | __GFP_HIGHMEM, + PAGE_KERNEL); - if (gfp_mask & __GFP_NORETRY) - noio_flag = memalloc_noio_save(); - - ptr = __vmalloc(c->block_size, gfp_mask | __GFP_HIGHMEM, PAGE_KERNEL); - - if (gfp_mask & __GFP_NORETRY) memalloc_noio_restore(noio_flag); + return ptr; + } - return ptr; + return __vmalloc(c->block_size, gfp_mask | __GFP_HIGHMEM, PAGE_KERNEL); } /*