From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_MUTT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 29F31C28D1E for ; Thu, 6 Jun 2019 12:53:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 028CD20868 for ; Thu, 6 Jun 2019 12:53:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728106AbfFFMx0 (ORCPT ); Thu, 6 Jun 2019 08:53:26 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:50137 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726822AbfFFMx0 (ORCPT ); Thu, 6 Jun 2019 08:53:26 -0400 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id E1AF980262; Thu, 6 Jun 2019 14:53:13 +0200 (CEST) Date: Thu, 6 Jun 2019 14:53:23 +0200 From: Pavel Machek To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, Arnd Bergmann , James Smart , "Martin K. Petersen" , Sasha Levin Subject: Re: [PATCH 4.19 237/276] scsi: lpfc: avoid uninitialized variable warning Message-ID: <20190606125323.GC27432@amd> References: <20190530030523.133519668@linuxfoundation.org> <20190530030539.944220603@linuxfoundation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="adJ1OR3c6QgCpb/j" Content-Disposition: inline In-Reply-To: <20190530030539.944220603@linuxfoundation.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --adJ1OR3c6QgCpb/j Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > [ Upstream commit faf5a744f4f8d76e7c03912b5cd381ac8045f6ec ] >=20 > clang -Wuninitialized incorrectly sees a variable being used without > initialization: >=20 > drivers/scsi/lpfc/lpfc_nvme.c:2102:37: error: variable 'localport' is uni= nitialized when used here > [-Werror,-Wuninitialized] > lport =3D (struct lpfc_nvme_lport *)localport->private; > ^~~~~~~~~ > drivers/scsi/lpfc/lpfc_nvme.c:2059:38: note: initialize the variable 'loc= alport' to silence this warning > struct nvme_fc_local_port *localport; > ^ > =3D NULL > 1 error generated. >=20 > This is clearly in dead code, as the condition leading up to it is always > false when CONFIG_NVME_FC is disabled, and the variable is always > initialized when nvme_fc_register_localport() got called successfully. >=20 > Change the preprocessor conditional to the equivalent C construct, which > makes the code more readable and gets rid of the warning. Unfortunately, this missed "else" branch where the code was freeing the memory with kfree(cstat)... so this introduces a memory leak. Best regards, Pavel > Signed-off-by: Arnd Bergmann > Acked-by: James Smart > Signed-off-by: Martin K. Petersen > Signed-off-by: Sasha Levin --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --adJ1OR3c6QgCpb/j Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAlz5DMMACgkQMOfwapXb+vL9mgCfWykgy5M4WHThY/CXqMxs9B8y 7BcAnikxGH2w2GgBe5Ox/uWDPPO4yA9q =n/8A -----END PGP SIGNATURE----- --adJ1OR3c6QgCpb/j--