Received: by 10.223.185.116 with SMTP id b49csp1037879wrg; Fri, 23 Feb 2018 10:47:10 -0800 (PST) X-Google-Smtp-Source: AH8x224uT8XIyywQcvh6beYiL6pkVauBWJ02CWWTEsdXJxGtsXz7vdDe3odRIlQ+WE9KnfVu42mj X-Received: by 2002:a17:902:a5c5:: with SMTP id t5-v6mr2642026plq.160.1519411630051; Fri, 23 Feb 2018 10:47:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519411630; cv=none; d=google.com; s=arc-20160816; b=XPhQ8pGI8+WGUMrk5Vv1WUT4bkdTsrNQIDGRjUr4Nn69lFtAV/VnpNYhRP1SQk12OC oPJqWqyGRkBkpAPZDimd8NeZSYeTkHutOiqXSgsQWvUwXo6gglRUbr8FXBG3UXTzIGw0 2plN3o2LmCsmAyULaC6drJ7cdFLqcxxC1dirGkqJ6j3etssOxqQkXaE0Ip+4fWf2SIWQ 2r3oT4I5khLEWV0f15tr2BdWRxQWSTX6ItnLMgsOagjzcjLcRrsH/SBfLmbErWNZXM3M XpLTdXXE9ocaltT4//LEkCnjFpHybxeA4kMNGk4FhAyxqImmVlH56FRi8xbgXzROScey k+kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=+BgWrR6c0QURyueQyf+uZl+IuvF6a/Mv9VcctJBoMgI=; b=W/nDMtQQ03Ta3whhGgAn7s+lJ9n1BCIqq+Q0N2azzMVbojnrWdT4EwEkkjBI3i4QBg 1+zTJIVO9Ks8bFr80iFP+yJG2sQ0fiqFCbhl5kpIN8lh3h/lz4v5msdBLgnOX4oSOJbU WFO7x7ZU5xe9Nt+DaYT2B3xVeTigVz/2ks2bolJtHHTNoiEgbMNjuG0S+hih0EooKpyN 1IlMQUT1NU7PhauXZ4NKoxnH/4yv2lSDRNVmyQPnmT2PiObUEgFF7yE3OdovH2hywqNb AKGxRgE3P+b44Vhi7fjqE9FB3LtEnIJA+9RH8upO+nlEhG6QNDqw/lmVc7wff1tKaaSx aeeQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t4si1826052pgv.79.2018.02.23.10.46.55; Fri, 23 Feb 2018 10:47:10 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934008AbeBWSqX (ORCPT + 99 others); Fri, 23 Feb 2018 13:46:23 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:43686 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933989AbeBWSqT (ORCPT ); Fri, 23 Feb 2018 13:46:19 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 881BB12DF; Fri, 23 Feb 2018 18:46:18 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Michal Hocko , "Kirill A. Shutemov" , Vlastimil Babka , Hugh Dickins , Andreas Gruenbacher , Andrew Morton , Linus Torvalds Subject: [PATCH 4.9 092/145] shmem: avoid maybe-uninitialized warning Date: Fri, 23 Feb 2018 19:26:38 +0100 Message-Id: <20180223170736.663120513@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170724.669759283@linuxfoundation.org> References: <20180223170724.669759283@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Arnd Bergmann commit 23f919d4ad0eb325595f10f55be4301b2965d6d6 upstream. After enabling -Wmaybe-uninitialized warnings, we get a false-postive warning for shmem: mm/shmem.c: In function `shmem_getpage_gfp': include/linux/spinlock.h:332:21: error: `info' may be used uninitialized in this function [-Werror=maybe-uninitialized] This can be easily avoided, since the correct 'info' pointer is known at the time we first enter the function, so we can simply move the initialization up. Moving it before the first label avoids the warning and lets us remove two later initializations. Note that the function is so hard to read that it not only confuses the compiler, but also most readers and without this patch it could\ easily break if one of the 'goto's changed. Link: https://www.spinics.net/lists/kernel/msg2368133.html Link: http://lkml.kernel.org/r/20161024205725.786455-1-arnd@arndb.de Signed-off-by: Arnd Bergmann Acked-by: Michal Hocko Acked-by: Kirill A. Shutemov Acked-by: Vlastimil Babka Cc: Hugh Dickins Cc: Andreas Gruenbacher Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- mm/shmem.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) --- a/mm/shmem.c +++ b/mm/shmem.c @@ -1550,7 +1550,7 @@ static int shmem_getpage_gfp(struct inod struct mm_struct *fault_mm, int *fault_type) { struct address_space *mapping = inode->i_mapping; - struct shmem_inode_info *info; + struct shmem_inode_info *info = SHMEM_I(inode); struct shmem_sb_info *sbinfo; struct mm_struct *charge_mm; struct mem_cgroup *memcg; @@ -1600,7 +1600,6 @@ repeat: * Fast cache lookup did not find it: * bring it back from swap or allocate. */ - info = SHMEM_I(inode); sbinfo = SHMEM_SB(inode->i_sb); charge_mm = fault_mm ? : current->mm; @@ -1852,7 +1851,6 @@ unlock: put_page(page); } if (error == -ENOSPC && !once++) { - info = SHMEM_I(inode); spin_lock_irq(&info->lock); shmem_recalc_inode(inode); spin_unlock_irq(&info->lock);