stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Lu Baolu <baolu.lu@linux.intel.com>,
	Guoqing Jiang <guoqing.jiang@linux.dev>,
	Joerg Roedel <jroedel@suse.de>
Subject: [PATCH 5.15 048/110] iommu/vt-d: Fix potential memory leak in intel_setup_irq_remapping()
Date: Mon,  7 Feb 2022 12:06:21 +0100	[thread overview]
Message-ID: <20220207103803.908885340@linuxfoundation.org> (raw)
In-Reply-To: <20220207103802.280120990@linuxfoundation.org>

From: Guoqing Jiang <guoqing.jiang@linux.dev>

commit 99e675d473eb8cf2deac1376a0f840222fc1adcf upstream.

After commit e3beca48a45b ("irqdomain/treewide: Keep firmware node
unconditionally allocated"). For tear down scenario, fn is only freed
after fail to allocate ir_domain, though it also should be freed in case
dmar_enable_qi returns error.

Besides free fn, irq_domain and ir_msi_domain need to be removed as well
if intel_setup_irq_remapping fails to enable queued invalidation.

Improve the rewinding path by add out_free_ir_domain and out_free_fwnode
lables per Baolu's suggestion.

Fixes: e3beca48a45b ("irqdomain/treewide: Keep firmware node unconditionally allocated")
Suggested-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Guoqing Jiang <guoqing.jiang@linux.dev>
Link: https://lore.kernel.org/r/20220119063640.16864-1-guoqing.jiang@linux.dev
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Link: https://lore.kernel.org/r/20220128031002.2219155-3-baolu.lu@linux.intel.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/iommu/intel/irq_remapping.c |   13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

--- a/drivers/iommu/intel/irq_remapping.c
+++ b/drivers/iommu/intel/irq_remapping.c
@@ -569,9 +569,8 @@ static int intel_setup_irq_remapping(str
 					    fn, &intel_ir_domain_ops,
 					    iommu);
 	if (!iommu->ir_domain) {
-		irq_domain_free_fwnode(fn);
 		pr_err("IR%d: failed to allocate irqdomain\n", iommu->seq_id);
-		goto out_free_bitmap;
+		goto out_free_fwnode;
 	}
 	iommu->ir_msi_domain =
 		arch_create_remap_msi_irq_domain(iommu->ir_domain,
@@ -595,7 +594,7 @@ static int intel_setup_irq_remapping(str
 
 		if (dmar_enable_qi(iommu)) {
 			pr_err("Failed to enable queued invalidation\n");
-			goto out_free_bitmap;
+			goto out_free_ir_domain;
 		}
 	}
 
@@ -619,6 +618,14 @@ static int intel_setup_irq_remapping(str
 
 	return 0;
 
+out_free_ir_domain:
+	if (iommu->ir_msi_domain)
+		irq_domain_remove(iommu->ir_msi_domain);
+	iommu->ir_msi_domain = NULL;
+	irq_domain_remove(iommu->ir_domain);
+	iommu->ir_domain = NULL;
+out_free_fwnode:
+	irq_domain_free_fwnode(fn);
 out_free_bitmap:
 	bitmap_free(bitmap);
 out_free_pages:



  parent reply	other threads:[~2022-02-07 11:49 UTC|newest]

Thread overview: 112+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-07 11:05 [PATCH 5.15 000/110] 5.15.22-rc1 review Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 001/110] drm/i915: Disable DSB usage for now Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 002/110] selinux: fix double free of cond_list on error paths Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 003/110] audit: improve audit queue handling when "audit=1" on cmdline Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 004/110] ipc/sem: do not sleep with a spin lock held Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 005/110] spi: stm32-qspi: Update spi registering Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 006/110] ASoC: hdmi-codec: Fix OOB memory accesses Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 007/110] ASoC: ops: Reject out of bounds values in snd_soc_put_volsw() Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 008/110] ASoC: ops: Reject out of bounds values in snd_soc_put_volsw_sx() Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 009/110] ASoC: ops: Reject out of bounds values in snd_soc_put_xr_sx() Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 010/110] ALSA: usb-audio: Correct quirk for VF0770 Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 011/110] ALSA: hda: Fix UAF of leds class devs at unbinding Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 012/110] ALSA: hda: realtek: Fix race at concurrent COEF updates Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 013/110] ALSA: hda/realtek: Add quirk for ASUS GU603 Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 014/110] ALSA: hda/realtek: Add missing fixup-model entry for Gigabyte X570 ALC1220 quirks Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 015/110] ALSA: hda/realtek: Fix silent output on Gigabyte X570S Aorus Master (newer chipset) Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 016/110] ALSA: hda/realtek: Fix silent output on Gigabyte X570 Aorus Xtreme after reboot from Windows Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 017/110] btrfs: dont start transaction for scrub if the fs is mounted read-only Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 018/110] btrfs: fix deadlock between quota disable and qgroup rescan worker Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 019/110] btrfs: fix use-after-free after failure to create a snapshot Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 020/110] Revert "fs/9p: search open fids first" Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 021/110] drm/nouveau: fix off by one in BIOS boundary checking Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 022/110] drm/i915/adlp: Fix TypeC PHY-ready status readout Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 023/110] drm/amd/pm: correct the MGpuFanBoost support for Beige Goby Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 024/110] drm/amd/display: watermark latencies is not enough on DCN31 Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 025/110] drm/amd/display: Force link_rate as LINK_RATE_RBR2 for 2018 15" Apple Retina panels Greg Kroah-Hartman
2022-02-07 11:05 ` [PATCH 5.15 026/110] nvme-fabrics: fix state check in nvmf_ctlr_matches_baseopts() Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 027/110] mm/debug_vm_pgtable: remove pte entry from the page table Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 028/110] mm/pgtable: define pte_index so that preprocessor could recognize it Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 029/110] mm/kmemleak: avoid scanning potential huge holes Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 030/110] block: bio-integrity: Advance seed correctly for larger interval sizes Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 031/110] dma-buf: heaps: Fix potential spectre v1 gadget Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 032/110] IB/hfi1: Fix AIP early init panic Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 033/110] Revert "fbcon: Disable accelerated scrolling" Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 034/110] fbcon: Add option to enable legacy hardware acceleration Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 035/110] mptcp: fix msk traversal in mptcp_nl_cmd_set_flags() Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 036/110] Revert "ASoC: mediatek: Check for error clk pointer" Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 037/110] KVM: arm64: Avoid consuming a stale esr value when SError occur Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 038/110] KVM: arm64: Stop handle_exit() from handling HVC twice when an SError occurs Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 039/110] RDMA/cma: Use correct address when leaving multicast group Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 040/110] RDMA/ucma: Protect mc during concurrent multicast leaves Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 041/110] RDMA/siw: Fix refcounting leak in siw_create_qp() Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 042/110] IB/rdmavt: Validate remote_addr during loopback atomic tests Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 043/110] RDMA/siw: Fix broken RDMA Read Fence/Resume logic Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 044/110] RDMA/mlx4: Dont continue event handler after memory allocation failure Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 045/110] ALSA: usb-audio: initialize variables that could ignore errors Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 046/110] ALSA: hda: Fix signedness of sscanf() arguments Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 047/110] ALSA: hda: Skip codec shutdown in case the codec is not registered Greg Kroah-Hartman
2022-02-07 11:06 ` Greg Kroah-Hartman [this message]
2022-02-07 11:06 ` [PATCH 5.15 049/110] iommu/amd: Fix loop timeout issue in iommu_ga_log_enable() Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 050/110] spi: bcm-qspi: check for valid cs before applying chip select Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 051/110] spi: mediatek: Avoid NULL pointer crash in interrupt Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 052/110] spi: meson-spicc: add IRQ check in meson_spicc_probe Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 053/110] spi: uniphier: fix reference count leak in uniphier_spi_probe() Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 054/110] IB/hfi1: Fix tstats alloc and dealloc Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 055/110] IB/cm: Release previously acquired reference counter in the cm_id_priv Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 056/110] net: ieee802154: hwsim: Ensure proper channel selection at probe time Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 057/110] net: ieee802154: mcr20a: Fix lifs/sifs periods Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 058/110] net: ieee802154: ca8210: Stop leaking skbs Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 059/110] netfilter: nft_reject_bridge: Fix for missing reply from prerouting Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 060/110] net: ieee802154: Return meaningful error codes from the netlink helpers Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 061/110] net/smc: Forward wakeup to smc socket waitqueue after fallback Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 062/110] net: stmmac: dwmac-visconti: No change to ETHER_CLOCK_SEL for unexpected speed request Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 063/110] net: stmmac: properly handle with runtime pm in stmmac_dvr_remove() Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 064/110] net: macsec: Fix offload support for NETDEV_UNREGISTER event Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 065/110] net: macsec: Verify that send_sci is on when setting Tx sci explicitly Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 066/110] net: stmmac: dump gmac4 DMA registers correctly Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 067/110] net: stmmac: ensure PTP time register reads are consistent Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 068/110] drm/kmb: Fix for build errors with Warray-bounds Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 069/110] drm/i915/overlay: Prevent divide by zero bugs in scaling Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 070/110] drm/amd: avoid suspend on dGPUs w/ s2idle support when runtime PM enabled Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 071/110] ASoC: fsl: Add missing error handling in pcm030_fabric_probe Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 072/110] ASoC: xilinx: xlnx_formatter_pcm: Make buffer bytes multiple of period bytes Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 073/110] ASoC: simple-card: fix probe failure on platform component Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 074/110] ASoC: cpcap: Check for NULL pointer after calling of_get_child_by_name Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 075/110] ASoC: max9759: fix underflow in speaker_gain_control_put() Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 076/110] ASoC: codecs: wcd938x: fix incorrect used of portid Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 077/110] ASoC: codecs: lpass-rx-macro: fix sidetone register offsets Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 078/110] ASoC: codecs: wcd938x: fix return value of mixer put function Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 079/110] pinctrl: sunxi: Fix H616 I2S3 pin data Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 080/110] pinctrl: intel: Fix a glitch when updating IRQ flags on a preconfigured line Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 081/110] pinctrl: intel: fix unexpected interrupt Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 082/110] pinctrl: bcm2835: Fix a few error paths Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 083/110] scsi: bnx2fc: Make bnx2fc_recv_frame() mp safe Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 084/110] nfsd: nfsd4_setclientid_confirm mistakenly expires confirmed client Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 085/110] gve: fix the wrong AdminQ buffer queue index check Greg Kroah-Hartman
2022-02-07 11:06 ` [PATCH 5.15 086/110] bpf: Use VM_MAP instead of VM_ALLOC for ringbuf Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 087/110] selftests/exec: Remove pipe from TEST_GEN_FILES Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 088/110] selftests: futex: Use variable MAKE instead of make Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 089/110] tools/resolve_btfids: Do not print any commands when building silently Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 090/110] e1000e: Separate ADP board type from TGP Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 091/110] rtc: cmos: Evaluate century appropriate Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 092/110] kvm/arm64: rework guest entry logic Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 093/110] perf: Copy perf_event_attr::sig_data on modification Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 094/110] perf stat: Fix display of grouped aliased events Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 095/110] perf/x86/intel/pt: Fix crash with stop filters in single-range mode Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 096/110] x86/perf: Default set FREEZE_ON_SMI for all Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 097/110] EDAC/altera: Fix deferred probing Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 098/110] EDAC/xgene: " Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 099/110] ext4: prevent used blocks from being allocated during fast commit replay Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 100/110] ext4: modify the logic of ext4_mb_new_blocks_simple Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 101/110] ext4: fix error handling in ext4_restore_inline_data() Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 102/110] ext4: fix error handling in ext4_fc_record_modified_inode() Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 103/110] ext4: fix incorrect type issue during replay_del_range Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 104/110] net: dsa: mt7530: make NET_DSA_MT7530 select MEDIATEK_GE_PHY Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 105/110] cgroup/cpuset: Fix "suspicious RCU usage" lockdep warning Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 106/110] tools include UAPI: Sync sound/asound.h copy with the kernel sources Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 107/110] gpio: idt3243x: Fix an ignored error return from platform_get_irq() Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 108/110] gpio: mpc8xxx: " Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 109/110] selftests: nft_concat_range: add test for reload with no element add/del Greg Kroah-Hartman
2022-02-07 11:07 ` [PATCH 5.15 110/110] selftests: netfilter: check stateless nat udp checksum fixup Greg Kroah-Hartman
2022-02-07 12:29 ` [PATCH 5.15 000/110] 5.15.22-rc1 review Naresh Kamboju

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=20220207103803.908885340@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=baolu.lu@linux.intel.com \
    --cc=guoqing.jiang@linux.dev \
    --cc=jroedel@suse.de \
    --cc=linux-kernel@vger.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).