]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob
351b10de2f77b6795ab169088ccb0b98e934b1fe
[thirdparty/kernel/stable-queue.git] /
1 From natechancellor@gmail.com Thu Jun 6 21:42:06 2019
2 From: Nathan Chancellor <natechancellor@gmail.com>
3 Date: Thu, 6 Jun 2019 10:41:25 -0700
4 Subject: scsi: lpfc: Fix backport of faf5a744f4f8 ("scsi: lpfc: avoid uninitialized variable warning")
5 To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
6 Cc: Pavel Machek <pavel@denx.de>, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Arnd Bergmann <arnd@arndb.de>, James Smart <james.smart@broadcom.com>, "Martin K. Petersen" <martin.petersen@oracle.com>, Sasha Levin <sashal@kernel.org>, Nathan Chancellor <natechancellor@gmail.com>
7 Message-ID: <20190606174125.4277-1-natechancellor@gmail.com>
8
9 From: Nathan Chancellor <natechancellor@gmail.com>
10
11 Prior to commit 4c47efc140fa ("scsi: lpfc: Move SCSI and NVME Stats to
12 hardware queue structures") upstream, we allocated a cstat structure in
13 lpfc_nvme_create_localport. When commit faf5a744f4f8 ("scsi: lpfc: avoid
14 uninitialized variable warning") was backported, it was placed after the
15 allocation so we leaked memory whenever this function was called and
16 that conditional was true (so whenever CONFIG_NVME_FC is disabled).
17
18 Move the IS_ENABLED if statement above the allocation since it is not
19 needed when the condition is true.
20
21 Reported-by: Pavel Machek <pavel@denx.de>
22 Signed-off-by: Nathan Chancellor <natechancellor@gmail.com>
23 Reviewed-by: James Smart <james.smart@broadcom.com>
24 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
25 ---
26 drivers/scsi/lpfc/lpfc_nvme.c | 6 +++---
27 1 file changed, 3 insertions(+), 3 deletions(-)
28
29 --- a/drivers/scsi/lpfc/lpfc_nvme.c
30 +++ b/drivers/scsi/lpfc/lpfc_nvme.c
31 @@ -2477,14 +2477,14 @@ lpfc_nvme_create_localport(struct lpfc_v
32 lpfc_nvme_template.max_sgl_segments = phba->cfg_nvme_seg_cnt + 1;
33 lpfc_nvme_template.max_hw_queues = phba->cfg_nvme_io_channel;
34
35 + if (!IS_ENABLED(CONFIG_NVME_FC))
36 + return ret;
37 +
38 cstat = kmalloc((sizeof(struct lpfc_nvme_ctrl_stat) *
39 phba->cfg_nvme_io_channel), GFP_KERNEL);
40 if (!cstat)
41 return -ENOMEM;
42
43 - if (!IS_ENABLED(CONFIG_NVME_FC))
44 - return ret;
45 -
46 /* localport is allocated from the stack, but the registration
47 * call allocates heap memory as well as the private area.
48 */