mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>,
	Mike Snitzer <snitzer@redhat.com>,
	Nathan Chancellor <natechancellor@gmail.com>
Subject: [PATCH 4.9 29/31] dm bufio: avoid false-positive Wmaybe-uninitialized warning
Date: Tue, 12 Jun 2018 18:46:32 +0200	[thread overview]
Message-ID: <20180612164621.948353741@linuxfoundation.org> (raw)
In-Reply-To: <20180612164620.797338191@linuxfoundation.org>

4.9-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Arnd Bergmann <arnd@arndb.de>

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 <arnd@arndb.de>
[snitzer: moved declarations inside conditional, altered vmalloc return]
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
[nc: Backport to 4.9, adjust context for lack of 19809c2da28a]
Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 drivers/md/dm-bufio.c |   17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

--- 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
 	 * 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);
 }
 
 /*



  parent reply	other threads:[~2018-06-12 16:48 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-12 16:46 [PATCH 4.9 00/31] 4.9.108-stable review Greg Kroah-Hartman
2018-06-12 16:46 ` [PATCH 4.9 01/31] tpm: do not suspend/resume if power stays on Greg Kroah-Hartman
2018-06-12 16:46 ` [PATCH 4.9 02/31] tpm: self test failure should not cause suspend to fail Greg Kroah-Hartman
2018-06-12 16:46 ` [PATCH 4.9 03/31] mmap: introduce sane default mmap limits Greg Kroah-Hartman
2018-06-12 16:46 ` [PATCH 4.9 04/31] mmap: relax file size limit for regular files Greg Kroah-Hartman
2018-06-12 16:46 ` [PATCH 4.9 05/31] btrfs: define SUPER_FLAG_METADUMP_V2 Greg Kroah-Hartman
2018-06-12 16:46 ` [PATCH 4.9 07/31] drm: set FMODE_UNSIGNED_OFFSET for drm files Greg Kroah-Hartman
2018-06-12 16:46 ` [PATCH 4.9 08/31] bnx2x: use the right constant Greg Kroah-Hartman
2018-06-12 16:46 ` [PATCH 4.9 09/31] dccp: dont free ccid2_hc_tx_sock struct in dccp_disconnect() Greg Kroah-Hartman
2018-06-12 16:46 ` [PATCH 4.9 10/31] enic: set DMA mask to 47 bit Greg Kroah-Hartman
2018-06-12 16:46 ` [PATCH 4.9 11/31] ip6mr: only set ip6mr_table from setsockopt when ip6mr_new_table succeeds Greg Kroah-Hartman
2018-06-12 16:46 ` [PATCH 4.9 12/31] ipv4: remove warning in ip_recv_error Greg Kroah-Hartman
2018-06-12 16:46 ` [PATCH 4.9 13/31] isdn: eicon: fix a missing-check bug Greg Kroah-Hartman
2018-06-12 16:46 ` [PATCH 4.9 14/31] kcm: Fix use-after-free caused by clonned sockets Greg Kroah-Hartman
2018-06-12 16:46 ` [PATCH 4.9 15/31] netdev-FAQ: clarify DaveMs position for stable backports Greg Kroah-Hartman
2018-06-12 16:46 ` [PATCH 4.9 16/31] net/packet: refine check for priv area size Greg Kroah-Hartman
2018-06-12 16:46 ` [PATCH 4.9 18/31] packet: fix reserve calculation Greg Kroah-Hartman
2018-06-12 16:46 ` [PATCH 4.9 19/31] qed: Fix mask for physical address in ILT entry Greg Kroah-Hartman
2018-06-12 16:46 ` [PATCH 4.9 20/31] sctp: not allow transport timeout value less than HZ/5 for hb_timer Greg Kroah-Hartman
2018-06-12 16:46 ` [PATCH 4.9 21/31] team: use netdev_features_t instead of u32 Greg Kroah-Hartman
2018-06-12 16:46 ` [PATCH 4.9 22/31] vhost: synchronize IOTLB message with dev cleanup Greg Kroah-Hartman
2018-06-12 16:46 ` [PATCH 4.9 23/31] vrf: check the original netdevice for generating redirect Greg Kroah-Hartman
2018-06-12 16:46 ` [PATCH 4.9 24/31] net/mlx4: Fix irq-unsafe spinlock usage Greg Kroah-Hartman
2018-06-12 16:46 ` [PATCH 4.9 25/31] rtnetlink: validate attributes in do_setlink() Greg Kroah-Hartman
2018-06-12 16:46 ` [PATCH 4.9 26/31] net: phy: broadcom: Fix bcm_write_exp() Greg Kroah-Hartman
2018-06-12 16:46 ` [PATCH 4.9 27/31] net: metrics: add proper netlink validation Greg Kroah-Hartman
2018-06-12 16:46 ` [PATCH 4.9 28/31] KVM: VMX: Expose SSBD properly to guests, 4.9 supplement Greg Kroah-Hartman
2018-06-12 16:46 ` Greg Kroah-Hartman [this message]
2018-06-12 16:46 ` [PATCH 4.9 30/31] objtool: Fix gcov check for older versions of GCC Greg Kroah-Hartman
2018-06-12 17:10 ` [PATCH 4.9 00/31] 4.9.108-stable review Nathan Chancellor
2018-06-12 17:45   ` Greg Kroah-Hartman
2018-06-12 20:58 ` Shuah Khan
2018-06-13  4:41   ` Greg Kroah-Hartman
2018-06-13 13:49 ` Guenter Roeck
2018-06-13 14:13 ` Rafael Tinoco
2018-06-13 14:42   ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180612164621.948353741@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=natechancellor@gmail.com \
    --cc=snitzer@redhat.com \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®