From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: stable@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
patches@lists.linux.dev, Rafael Mendonca <rafaelmendsr@gmail.com>,
James Smart <jsmart2021@gmail.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.15 44/79] scsi: lpfc: Fix memory leak in lpfc_create_port()
Date: Thu, 27 Oct 2022 18:55:42 +0200 [thread overview]
Message-ID: <20221027165056.375693146@linuxfoundation.org> (raw)
In-Reply-To: <20221027165054.917467648@linuxfoundation.org>
From: Rafael Mendonca <rafaelmendsr@gmail.com>
[ Upstream commit dc8e483f684a24cc06e1d5fa958b54db58855093 ]
Commit 5e633302ace1 ("scsi: lpfc: vmid: Add support for VMID in mailbox
command") introduced allocations for the VMID resources in
lpfc_create_port() after the call to scsi_host_alloc(). Upon failure on the
VMID allocations, the new code would branch to the 'out' label, which
returns NULL without unwinding anything, thus skipping the call to
scsi_host_put().
Fix the problem by creating a separate label 'out_free_vmid' to unwind the
VMID resources and make the 'out_put_shost' label call only
scsi_host_put(), as was done before the introduction of allocations for
VMID.
Fixes: 5e633302ace1 ("scsi: lpfc: vmid: Add support for VMID in mailbox command")
Signed-off-by: Rafael Mendonca <rafaelmendsr@gmail.com>
Link: https://lore.kernel.org/r/20220916035908.712799-1-rafaelmendsr@gmail.com
Reviewed-by: James Smart <jsmart2021@gmail.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/scsi/lpfc/lpfc_init.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c
index 33e33fff8986..48043e1ba485 100644
--- a/drivers/scsi/lpfc/lpfc_init.c
+++ b/drivers/scsi/lpfc/lpfc_init.c
@@ -4666,7 +4666,7 @@ lpfc_create_port(struct lpfc_hba *phba, int instance, struct device *dev)
rc = lpfc_vmid_res_alloc(phba, vport);
if (rc)
- goto out;
+ goto out_put_shost;
/* Initialize all internally managed lists. */
INIT_LIST_HEAD(&vport->fc_nodes);
@@ -4684,16 +4684,17 @@ lpfc_create_port(struct lpfc_hba *phba, int instance, struct device *dev)
error = scsi_add_host_with_dma(shost, dev, &phba->pcidev->dev);
if (error)
- goto out_put_shost;
+ goto out_free_vmid;
spin_lock_irq(&phba->port_list_lock);
list_add_tail(&vport->listentry, &phba->port_list);
spin_unlock_irq(&phba->port_list_lock);
return vport;
-out_put_shost:
+out_free_vmid:
kfree(vport->vmid);
bitmap_free(vport->vmid_priority_range);
+out_put_shost:
scsi_host_put(shost);
out:
return NULL;
--
2.35.1
next prev parent reply other threads:[~2022-10-27 17:02 UTC|newest]
Thread overview: 86+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-27 16:54 [PATCH 5.15 00/79] 5.15.76-rc1 review Greg Kroah-Hartman
2022-10-27 16:54 ` [PATCH 5.15 01/79] r8152: add PID for the Lenovo OneLink+ Dock Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 02/79] arm64/mm: Consolidate TCR_EL1 fields Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 03/79] usb: gadget: uvc: consistently use define for headerlen Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 04/79] usb: gadget: uvc: use on returned header len in video_encode_isoc_sg Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 05/79] usb: gadget: uvc: rework uvcg_queue_next_buffer to uvcg_complete_buffer Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 06/79] usb: gadget: uvc: giveback vb2 buffer on req complete Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 07/79] usb: gadget: uvc: improve sg exit condition Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 08/79] arm64: errata: Remove AES hwcap for COMPAT tasks Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 09/79] perf/x86/intel/pt: Relax address filter validation Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 10/79] btrfs: enhance unsupported compat RO flags handling Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 11/79] ocfs2: clear dinode links count in case of error Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 12/79] ocfs2: fix BUG when iput after ocfs2_mknod fails Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 13/79] selinux: enable use of both GFP_KERNEL and GFP_ATOMIC in convert_context() Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 14/79] cpufreq: qcom: fix writes in read-only memory region Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 15/79] i2c: qcom-cci: Fix ordering of pm_runtime_xx and i2c_add_adapter Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 16/79] cpufreq: tegra194: Fix module loading Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 17/79] x86/microcode/AMD: Apply the patch early on every logical thread Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 18/79] hwmon/coretemp: Handle large core ID value Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 19/79] ata: ahci-imx: Fix MODULE_ALIAS Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 20/79] ata: ahci: Match EM_MAX_SLOTS with SATA_PMP_MAX_PORTS Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 21/79] x86/resctrl: Fix min_cbm_bits for AMD Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 22/79] cpufreq: qcom: fix memory leak in error path Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 23/79] drm/amdgpu: fix sdma doorbell init ordering on APUs Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 24/79] mm,hugetlb: take hugetlb_lock before decrementing h->resv_huge_pages Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 25/79] kvm: Add support for arch compat vm ioctls Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 26/79] KVM: arm64: vgic: Fix exit condition in scan_its_table() Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 27/79] media: ipu3-imgu: Fix NULL pointer dereference in active selection access Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 28/79] media: mceusb: set timeout to at least timeout provided Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 29/79] media: venus: dec: Handle the case where find_format fails Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 30/79] x86/topology: Fix multiple packages shown on a single-package system Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 31/79] x86/topology: Fix duplicated core ID within a package Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 32/79] btrfs: fix processing of delayed data refs during backref walking Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 33/79] btrfs: fix processing of delayed tree block " Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 34/79] drm/vc4: Add module dependency on hdmi-codec Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 35/79] ACPI: extlog: Handle multiple records Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 36/79] tipc: Fix recognition of trial period Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 37/79] tipc: fix an information leak in tipc_topsrv_kern_subscr Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 38/79] i40e: Fix DMA mappings leak Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 39/79] HID: magicmouse: Do not set BTN_MOUSE on double report Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 40/79] sfc: Change VF mac via PF as first preference if available Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 41/79] net/atm: fix proc_mpc_write incorrect return value Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 42/79] net: phy: dp83867: Extend RX strap quirk for SGMII mode Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 43/79] net: phylink: add mac_managed_pm in phylink_config structure Greg Kroah-Hartman
2022-10-27 16:55 ` Greg Kroah-Hartman [this message]
2022-10-27 16:55 ` [PATCH 5.15 45/79] udp: Update reuse->has_conns under reuseport_lock Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 46/79] cifs: Fix xid leak in cifs_create() Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 47/79] cifs: Fix xid leak in cifs_copy_file_range() Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 48/79] cifs: Fix xid leak in cifs_flock() Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 49/79] cifs: Fix xid leak in cifs_ses_add_channel() Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 50/79] dm: remove unnecessary assignment statement in alloc_dev() Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 51/79] net: hsr: avoid possible NULL deref in skb_clone() Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 52/79] ionic: catch NULL pointer issue on reconfig Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 53/79] netfilter: nf_tables: relax NFTA_SET_ELEM_KEY_END set flags requirements Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 54/79] nvme-hwmon: consistently ignore errors from nvme_hwmon_init Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 55/79] nvme-hwmon: kmalloc the NVME SMART log buffer Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 56/79] nvmet: fix workqueue MEM_RECLAIM flushing dependency Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 57/79] net: sched: cake: fix null pointer access issue when cake_init() fails Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 58/79] net: sched: delete duplicate cleanup of backlog and qlen Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 59/79] net: sched: sfb: fix null pointer access issue when sfb_init() fails Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 60/79] sfc: include vport_id in filter spec hash and equal() Greg Kroah-Hartman
2022-10-27 16:55 ` [PATCH 5.15 61/79] wwan_hwsim: fix possible memory leak in wwan_hwsim_dev_new() Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.15 62/79] net: hns: fix possible memory leak in hnae_ae_register() Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.15 63/79] net: sched: fix race condition in qdisc_graft() Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.15 64/79] net: phy: dp83822: disable MDI crossover status change interrupt Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.15 65/79] iommu/vt-d: Allow NVS regions in arch_rmrr_sanity_check() Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.15 66/79] iommu/vt-d: Clean up si_domain in the init_dmars() error path Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.15 67/79] fs: dlm: fix invalid derefence of sb_lvbptr Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.15 68/79] arm64: mte: move register initialization to C Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.15 69/79] ksmbd: handle smb2 query dir request for OutputBufferLength that is too small Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.15 70/79] ksmbd: fix incorrect handling of iterate_dir Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.15 71/79] tracing: Simplify conditional compilation code in tracing_set_tracer() Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.15 72/79] tracing: Do not free snapshot if tracer is on cmdline Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.15 73/79] mmc: sdhci-tegra: Use actual clock rate for SW tuning correction Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.15 74/79] perf: Skip and warn on unknown format configN attrs Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.15 75/79] [PATCH v3] ACPI: video: Force backlight native for more TongFang devices Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.15 76/79] x86/Kconfig: Drop check for -mabi=ms for CONFIG_EFI_STUB Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.15 77/79] Makefile.debug: re-enable debug info for .S files Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.15 78/79] mmc: core: Add SD card quirk for broken discard Greg Kroah-Hartman
2022-10-27 16:56 ` [PATCH 5.15 79/79] mm: /proc/pid/smaps_rollup: fix no vmas null-deref Greg Kroah-Hartman
2022-10-27 18:18 ` [PATCH 5.15 00/79] 5.15.76-rc1 review Guenter Roeck
2022-10-28 10:42 ` Greg Kroah-Hartman
2022-10-28 3:46 ` Bagas Sanjaya
2022-10-28 9:58 ` Naresh Kamboju
2022-10-28 10:40 ` Sudip Mukherjee (Codethink)
2022-10-28 10:44 ` Sudip Mukherjee
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221027165056.375693146@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=jsmart2021@gmail.com \
--cc=martin.petersen@oracle.com \
--cc=patches@lists.linux.dev \
--cc=rafaelmendsr@gmail.com \
--cc=sashal@kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).