Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp2512368imd; Sun, 28 Oct 2018 11:39:04 -0700 (PDT) X-Google-Smtp-Source: AJdET5cFUEoPsZkox3q68yAli4sdQ8fNH2dZlIkVRT0hAabOhZlPs5iYS546h6m6CI9iXIr8AIgu X-Received: by 2002:a62:8647:: with SMTP id x68-v6mr12544210pfd.252.1540751944796; Sun, 28 Oct 2018 11:39:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540751944; cv=none; d=google.com; s=arc-20160816; b=kETdshrsFyS1PCSwrDM+So9PZNa7mKuyVsZAQ3+81mcNOEIhooX+BpibCCJG2SJKnt 3n683os7wl6yBjDtHmqyEem6thXI8dvIxwWF/707OAQZahIJKMgFKpYzKaxLCVBohbMX IqFglbG7ovnegcQzqVUlqdJs7eMBS4poj5XYZlKtNOP1siDD0kSlyCPm0XrQ9BqKHPBE 88B0aHDcSerNFnUn/ZF3jeJUm3URvljx8uGW2y5Fd4GHUMJNabzSTX9MN2yjQStm5zCn ULZBcTfTLO9Da8Bkh/ohnYOKFk6IdCSfXigIDGxvQGEx40i3bFEK6Z2fQ0x3iyerzjLO g7Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=JawUiS6yl5PWFfA1n7wCgqH2PS+44iYpdZ2SRlWC0B8=; b=WFm4cG3hMhqD57PWgsXz0nU8CFoyNHC2u5zc8iyqKJXuGIbNbGPQcgWIFOFsuIbKNP SoWBPFzovRjVb/kkrxc2bGehDf0wEMjoWOynrxH2RHE8WgQMgv1tq9+UWk6Vf3t1lEWS Ag4Rau3jZoHg72gvG1PS25Mp8Q9N/FOrK7u/OHHjDe9BHVzHLbvzcaKSvKrqRTm7vpAy zCTBb7knUJLOlD575kIjrt2PFVvvshq9CVRu9FCnaQcVXvFaST2xnKg9eMNkR7gEtIkv 6Tx3qeabY4V6f2lMhjCCJcukJQMtfhCvS3FOE0pylcqxpPKlh7kcVw183S+6cnjmo3Ja V0uQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b="S/czunjC"; 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 h13-v6si4751101pgj.457.2018.10.28.11.38.48; Sun, 28 Oct 2018 11:39:04 -0700 (PDT) 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; dkim=pass header.i=@lightnvm-io.20150623.gappssmtp.com header.s=20150623 header.b="S/czunjC"; 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 S1726556AbeJ2DX4 (ORCPT + 99 others); Sun, 28 Oct 2018 23:23:56 -0400 Received: from mail-lf1-f66.google.com ([209.85.167.66]:37551 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726426AbeJ2DXz (ORCPT ); Sun, 28 Oct 2018 23:23:55 -0400 Received: by mail-lf1-f66.google.com with SMTP id a82-v6so4377645lfa.4 for ; Sun, 28 Oct 2018 11:38:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lightnvm-io.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=JawUiS6yl5PWFfA1n7wCgqH2PS+44iYpdZ2SRlWC0B8=; b=S/czunjCL4Mw44i59SyQNzVjZlUeftMEDzkt+TdvSP7QrYK0ikBfnk3Xxy6FGTJIAa J53DveY9sXTPSdkkFFo9LWrr3KZXZD3y4qWoYbN69Uz7/kjiJ1XutDS0IsG8DEEGf+81 cQiWHPMmhyDEMGLYREgsPQVpddWtbZEjV6oVBO1+ZsLBYnB99OxQy6LL5yNM8ky2ltVc rLqgFIA3k4bEnFmrLB4ktBdaVlxjwNjlS2HfCUrV4FzZvP6L1h3nK6UM+OcKyW2AIV8a htx9fxtzt8ZeyYSEQvLojOpFZhJGyhT1zvwNbJ2WmCUyrzazwcgPnBJoK63Sz4B13NF7 BgOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=JawUiS6yl5PWFfA1n7wCgqH2PS+44iYpdZ2SRlWC0B8=; b=VaS4ftUyfBOFDIA0MpXXh422oYY96hKSU+fyo9t7uBxSXXBH6+SyayzSEp+fvI1CgG YvfTphBNsd8waVIQxkGwa+8hxfyCTDLecOy2HlZOPtmsl9WbqjX2NOeyB020nXgh1JKP hZB0Ovhr0v3J3wDMRG0Dt6Sr0yyX7/hv72NcSFJLNnGD06GOehpU9c9hInvEd+aZh8AH Et7bmZi4j1kjVCxQ76nb45VikeDNajhqrrim4sAECSk7AjUs/dEpVym+tyXI25X4YkWx ehIEWy6PLBJW5OOeTd6kompVYux7TiSWV5Zlkk0mTZDSlUUj8fejt/K4ltQuyDHAuZKV RWZA== X-Gm-Message-State: AGRZ1gI+R5T69PSilwypkNHVlhPIv74qBtTkLYh20pkwZAaqGLRdc2ag SB5PBsBJ79KZhiR/LqgS2+7aa+1ybKw= X-Received: by 2002:a19:4e59:: with SMTP id c86mr6761660lfb.132.1540751906039; Sun, 28 Oct 2018 11:38:26 -0700 (PDT) Received: from [192.168.0.36] (95-166-82-66-cable.dk.customer.tdc.net. [95.166.82.66]) by smtp.googlemail.com with ESMTPSA id u65sm380454lff.54.2018.10.28.11.38.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Oct 2018 11:38:24 -0700 (PDT) Subject: Re: [PATCH] lightnvm: Fix uninitialized return value in nvm_get_chunk_meta() To: geert@linux-m68k.org, keith.busch@intel.com, axboe@fb.com, hch@lst.de, sagi@grimberg.me Cc: arnd@arndb.de, linux-block@vger.kernel.org, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org References: <20181028160726.24450-1-geert@linux-m68k.org> From: =?UTF-8?Q?Matias_Bj=c3=b8rling?= Message-ID: Date: Sun, 28 Oct 2018 19:38:23 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181028160726.24450-1-geert@linux-m68k.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 10/28/2018 05:07 PM, Geert Uytterhoeven wrote: > With gcc 4.1: > > drivers/lightnvm/core.c: In function ‘nvm_get_bb_meta’: > drivers/lightnvm/core.c:977: warning: ‘ret’ may be used uninitialized in this function > > and > > drivers/nvme/host/lightnvm.c: In function ‘nvme_nvm_get_chk_meta’: > drivers/nvme/host/lightnvm.c:580: warning: ‘ret’ may be used uninitialized in this function > > Indeed, if (for the former) the number of channels or LUNs is zero, or > (for both) the passed number of chunks is zero, ret will be returned > uninitialized. > > Fix this by preinitializing ret to zero. > > Fixes: aff3fb18f957de93 ("lightnvm: move bad block and chunk state logic to core") > Fixes: a294c199455187d1 ("lightnvm: implement get log report chunk helpers") > Signed-off-by: Geert Uytterhoeven > --- > I don't know if this can happen in practice, but given this is core > functionality that can be called from other files, or even from other > modules, I think it's better to be safe than sorry. > > The latter seems to be a pre-existing issue since v4.17. > I didn't notice it before, due to the dependency of NVM on PCI (my gcc > 4.1 targets m68k, i.e. no PCI). > --- > drivers/lightnvm/core.c | 2 +- > drivers/nvme/host/lightnvm.c | 3 ++- > 2 files changed, 3 insertions(+), 2 deletions(-) > > diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c > index efb976a863d2295a..73ab3cf2686804ba 100644 > --- a/drivers/lightnvm/core.c > +++ b/drivers/lightnvm/core.c > @@ -974,7 +974,7 @@ static int nvm_get_bb_meta(struct nvm_dev *dev, sector_t slba, > struct ppa_addr ppa; > u8 *blks; > int ch, lun, nr_blks; > - int ret; > + int ret = 0; > > ppa.ppa = slba; > ppa = dev_to_generic_addr(dev, ppa); > diff --git a/drivers/nvme/host/lightnvm.c b/drivers/nvme/host/lightnvm.c > index a4f3b263cd6c60ee..d64805dc8efbaa02 100644 > --- a/drivers/nvme/host/lightnvm.c > +++ b/drivers/nvme/host/lightnvm.c > @@ -577,7 +577,8 @@ static int nvme_nvm_get_chk_meta(struct nvm_dev *ndev, > struct ppa_addr ppa; > size_t left = nchks * sizeof(struct nvme_nvm_chk_meta); > size_t log_pos, offset, len; > - int ret, i, max_len; > + int i, max_len; > + int ret = 0; > > /* > * limit requests to maximum 256K to avoid issuing arbitrary large > Thanks Geert. Applied for 4.21/5.1.