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=-6.0 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE, SPF_PASS,T_DKIMWL_WL_HIGH,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 0E387C2BCA1 for ; Fri, 7 Jun 2019 15:46:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CDE60212F5 for ; Fri, 7 Jun 2019 15:46:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559922397; bh=8QlJJdFA43+I5a1OP0oP2z71pKHVQ6ZQmOOq+9J9Ni8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=nSwWMwhhOyIvHV0quQOvtvLXxGfg39kSjYATxvbrzraksEX+u7QX4xuiZV1K/gzqi +xCOT+qcQFa0VL+33YZkbIMGbWpyfC6TM/hKoR69V71i38/DAk8jf1+7O31FusZ+GF my2cn6yc6hxKkMrOmK4iXT31MHM2CzQQoitA43Fc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731440AbfFGPqh (ORCPT ); Fri, 7 Jun 2019 11:46:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:58962 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731421AbfFGPqe (ORCPT ); Fri, 7 Jun 2019 11:46:34 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 75670212F5; Fri, 7 Jun 2019 15:46:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1559922394; bh=8QlJJdFA43+I5a1OP0oP2z71pKHVQ6ZQmOOq+9J9Ni8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t9y2g8wOKSinzFUm/J0GxiWCchqOqhpYP6yg9GoeGpH7gD1OJzlsZKxdby4qzzQ7n j2Gf2S2fAga3zFI0qhjWRNkiQ6rm/8pVrwQSzXe6JSF65WLDdaw5j+G5ILAcsfM0Af eEEkO/SXIEWrtxl3fjKpv1Q4gFV9eljGf1EPnV50= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Machek , Nathan Chancellor , James Smart Subject: [PATCH 4.19 70/73] scsi: lpfc: Fix backport of faf5a744f4f8 ("scsi: lpfc: avoid uninitialized variable warning") Date: Fri, 7 Jun 2019 17:39:57 +0200 Message-Id: <20190607153856.615668534@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190607153848.669070800@linuxfoundation.org> References: <20190607153848.669070800@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nathan Chancellor 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 Reviewed-by: James Smart Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/lpfc/lpfc_nvme.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/scsi/lpfc/lpfc_nvme.c +++ b/drivers/scsi/lpfc/lpfc_nvme.c @@ -2477,14 +2477,14 @@ lpfc_nvme_create_localport(struct lpfc_v 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. */