Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp8420494ybi; Thu, 6 Jun 2019 12:02:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqyx+4d9frgzAMyENY6r+9Th+dSRwuTGr7pC1tVTkhsMQEa8Jqg5Rj6UIzeasTF4agMAXoo2 X-Received: by 2002:a17:90a:8e86:: with SMTP id f6mr1331145pjo.66.1559847721571; Thu, 06 Jun 2019 12:02:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559847721; cv=none; d=google.com; s=arc-20160816; b=Ft197lJbhdfxcyVLr568NXo3bdPw5RNe1+fNr8tyTHJLM0Z1Bg5E7b8efoHJToXC22 bj/Q5F33pnr3ss0LhzpqGDC6SEU1VMbuVTO8zKXaql1pm7QAc5fnJ4jnTvocH0HJNDXf sRMFdvAw5gYpW4K1fIuVPg+chILFz4nPqFJ1KHE3KQ3Ycgi/FFKbcJPhUIDMmsasxAXd BloBgraYs38UKtaQ1j4hAXkDFzVYNwyvy55dvr+FaNW/zJO8fhDSj4T3dm8LA4Z42q/I PObBtrR+TC+zUXxI3VToCOhS8dldyd31o325Qo2+X/7BZniIODByisIr9rWlxRj8qXk1 zVbw== 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:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ep+lClRkBZiSpttevvAOjGUX9zV5Sv5RO5bhSwT85Pk=; b=sxkxW7jtS5h/w+01zuC1+uBjT91b7aanYhz9aleO82Dtu6caWr+6NKktKxQDB2DSbo HQA/hQEB1d5Oo+liE3xA4+QElVsITA4VYU1N+G6yOyB+kIVdvcbMMr/LuBAc49tw4TA4 Md2YYqjgfZij2bJx7QOaBSjGHzgwkHQxJ4DfMWig4i7gk15LwxpoVxJQ4SHPGAmmS0dI 8+jQLTegaF6H0xEkgC73K9zaCKlgU2+2a9X20YVhrjErqJwKf0FVRmnUrd8/GHFk/qTV Kgjj7Y74PG3De68bTayOUBJidt6QshOGPSyGz5WysVHnBpKB8ZNDcR7u5XF7crTq4ltx Rbww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="KkiW/xNC"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y24si2675977pgh.372.2019.06.06.12.01.44; Thu, 06 Jun 2019 12:02:01 -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=@gmail.com header.s=20161025 header.b="KkiW/xNC"; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730245AbfFFRlt (ORCPT + 99 others); Thu, 6 Jun 2019 13:41:49 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:37021 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728879AbfFFRls (ORCPT ); Thu, 6 Jun 2019 13:41:48 -0400 Received: by mail-ed1-f67.google.com with SMTP id w13so4517979eds.4; Thu, 06 Jun 2019 10:41:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ep+lClRkBZiSpttevvAOjGUX9zV5Sv5RO5bhSwT85Pk=; b=KkiW/xNCXMwCGoC0JNOZVCNnHMbJ/x14FhvcKNzpcJUKcIjeNtiHET8JVhVAjuwMdJ 31dggq3pab3WtEQzLRDJY2PiXEeEcQvbLaGQv9goeQNKJQNR1c2kyOFx7liWBwrUWbTP +yLr+kPukq/L9Y0PD88z/gRmmLnkT8h/OoOxrG67otwhdlVEkxvBfxgCFSYWrA3an1WP PzFCAOXYQ0JRM4evxnZXGdDgP5wSOrNpDOFOXkVcQG8HzQf3g/cAf6Xyyf8t4T0Vfsvp nKo42//+mE0Ef85esn1p1MCFrToWh6tX9jBLIJOxLOtHELeomS4yyqF+dS6wfFKLzVr9 sX8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ep+lClRkBZiSpttevvAOjGUX9zV5Sv5RO5bhSwT85Pk=; b=tNsLARheiUV7zuJeWEOsMxahDmN940nrGuqGJ037d96JYuMSt1FS4tENmTG3j7mIhp pjTCkCfyGsQXWIyZyCzZDLXzUtA0W6ux+AcUgpnIuEboIMyl8Wkt4ie9LgpxSZRSWAD0 WuILQpProTX0AycOkxQlU5NfDLN5xl25byvQZem49SbD/YaMwfKIHy0WJmmDPr/0R6YY R6l9zcdYoBtR4wHxiu3lk5gpBrDSQlzrEG1iMM61pKnU7uDQ40bEa4MBvU8pSV7qvkte I/FD5sLRVdi77ZOyfsP0q3WJOn1ygUP/TR0LBaA4zDPyN8H9ekYoy05G+MRwtHHUpVGh 7KPQ== X-Gm-Message-State: APjAAAWumJTqmNUUl1nTIV0dXmLPzxzES7XzREieYSo8KNudm4YwJmwq UjScKyrl4nmiZh8iWnGZVFA= X-Received: by 2002:a17:906:13c7:: with SMTP id g7mr43293906ejc.1.1559842906721; Thu, 06 Jun 2019 10:41:46 -0700 (PDT) Received: from localhost.localdomain ([2a01:4f9:2b:2b15::2]) by smtp.gmail.com with ESMTPSA id w5sm617172edd.19.2019.06.06.10.41.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 06 Jun 2019 10:41:46 -0700 (PDT) From: Nathan Chancellor To: Greg Kroah-Hartman Cc: Pavel Machek , linux-kernel@vger.kernel.org, stable@vger.kernel.org, Arnd Bergmann , James Smart , "Martin K. Petersen" , Sasha Levin , Nathan Chancellor Subject: [PATCH] scsi: lpfc: Fix backport of faf5a744f4f8 ("scsi: lpfc: avoid uninitialized variable warning") Date: Thu, 6 Jun 2019 10:41:25 -0700 Message-Id: <20190606174125.4277-1-natechancellor@gmail.com> X-Mailer: git-send-email 2.22.0.rc3 In-Reply-To: <20190606165346.GB3249@kroah.com> References: <20190606165346.GB3249@kroah.com> MIME-Version: 1.0 X-Patchwork-Bot: notify Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Prior to commit 4c47efc140fa ("scsi: lpfc: Move SCSI and NVME Stats to hardware queue structures") upstream, we allocated a cstat structure in lpfc_nvme_create_localport. When commit faf5a744f4f8 ("scsi: lpfc: avoid uninitialized variable warning") was backported, it was placed after the allocation so we leaked memory whenever this function was called and that conditional was true (so whenever CONFIG_NVME_FC is disabled). Move the IS_ENABLED if statement above the allocation since it is not needed when the condition is true. Reported-by: Pavel Machek Signed-off-by: Nathan Chancellor --- drivers/scsi/lpfc/lpfc_nvme.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/lpfc/lpfc_nvme.c b/drivers/scsi/lpfc/lpfc_nvme.c index 099f70798fdd..645ffb5332b4 100644 --- a/drivers/scsi/lpfc/lpfc_nvme.c +++ b/drivers/scsi/lpfc/lpfc_nvme.c @@ -2477,14 +2477,14 @@ lpfc_nvme_create_localport(struct lpfc_vport *vport) lpfc_nvme_template.max_sgl_segments = phba->cfg_nvme_seg_cnt + 1; lpfc_nvme_template.max_hw_queues = phba->cfg_nvme_io_channel; + if (!IS_ENABLED(CONFIG_NVME_FC)) + return ret; + cstat = kmalloc((sizeof(struct lpfc_nvme_ctrl_stat) * phba->cfg_nvme_io_channel), GFP_KERNEL); if (!cstat) return -ENOMEM; - if (!IS_ENABLED(CONFIG_NVME_FC)) - return ret; - /* localport is allocated from the stack, but the registration * call allocates heap memory as well as the private area. */ -- 2.22.0.rc3