From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753917AbdIESie (ORCPT ); Tue, 5 Sep 2017 14:38:34 -0400 Received: from mga07.intel.com ([134.134.136.100]:13265 "EHLO mga07.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753535AbdIEShc (ORCPT ); Tue, 5 Sep 2017 14:37:32 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.41,480,1498546800"; d="scan'208";a="1191821428" Date: Tue, 5 Sep 2017 12:37:30 -0600 From: Ross Zwisler To: Nicolas Iooss , Andrew Morton Cc: Matthew Wilcox , Ross Zwisler , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/1] dax: initialize variable pfn before using it Message-ID: <20170905183730.GA24073@linux.intel.com> Mail-Followup-To: Ross Zwisler , Nicolas Iooss , Andrew Morton , Matthew Wilcox , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org References: <20170903083000.587-1-nicolas.iooss_linux@m4x.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170903083000.587-1-nicolas.iooss_linux@m4x.org> User-Agent: Mutt/1.8.3 (2017-05-23) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Sep 03, 2017 at 10:30:00AM +0200, Nicolas Iooss wrote: > Function dax_pmd_insert_mapping() contains the following code: > > pfn_t pfn; > if (bdev_dax_pgoff(bdev, sector, size, &pgoff) != 0) > goto fallback; > /* ... */ > fallback: > trace_dax_pmd_insert_mapping_fallback(inode, vmf, length, pfn, ret); > > When the condition in the if statement fails, the function calls > trace_dax_pmd_insert_mapping_fallback() with an uninitialized pfn value. > > This issue has been found while building the kernel with clang. The > compiler reported: > > fs/dax.c:1280:6: error: variable 'pfn' is used uninitialized > whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized] > if (bdev_dax_pgoff(bdev, sector, size, &pgoff) != 0) > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > fs/dax.c:1310:60: note: uninitialized use occurs here > trace_dax_pmd_insert_mapping_fallback(inode, vmf, length, pfn, ret); > ^~~ > > Signed-off-by: Nicolas Iooss Yep this looks good. Thanks for the fix. Reviewed-by: Ross Zwisler > --- > fs/dax.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/dax.c b/fs/dax.c > index ab925dc6647a..20e6d76d6fff 100644 > --- a/fs/dax.c > +++ b/fs/dax.c > @@ -1283,7 +1283,7 @@ static int dax_pmd_insert_mapping(struct vm_fault *vmf, struct iomap *iomap, > void *ret = NULL, *kaddr; > long length = 0; > pgoff_t pgoff; > - pfn_t pfn; > + pfn_t pfn = {}; > int id; > > if (bdev_dax_pgoff(bdev, sector, size, &pgoff) != 0) > -- > 2.14.1 >