From: Antti Laakso <antti.laakso@linux.intel.com>
To: linux-media@vger.kernel.org, sakari.ailus@linux.intel.com,
sarang.sapre@intel.com, error27@gmail.com
Subject: [PATCH] media: ipu6: Fix bus device use-after-free
Date: Thu, 24 Sep 2026 15:06:34 +0300 [thread overview]
Message-ID: <20260924120634.1420687-1-antti.laakso@linux.intel.com> (raw)
The ipu6_bus_del_devices() will uninitialize and free bus devices and
dereferencing isp->psys and isp->isys will lead to use-after-free.
While at it, remove unnecessary checks for isp->isys/psys.
Reported-by: Dan Carpenter <error27@gmail.com>
Fixes: 69ebb1bfc865 ("media: ipu6: Move isys fw mapping to pci_probe")
Signed-off-by: Antti Laakso <antti.laakso@linux.intel.com>
---
drivers/media/pci/intel/ipu6/ipu6.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/drivers/media/pci/intel/ipu6/ipu6.c b/drivers/media/pci/intel/ipu6/ipu6.c
index 43d951735f72..b9a79181d736 100644
--- a/drivers/media/pci/intel/ipu6/ipu6.c
+++ b/drivers/media/pci/intel/ipu6/ipu6.c
@@ -836,6 +836,8 @@ static int ipu6_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
static void ipu6_pci_remove(struct pci_dev *pdev)
{
struct ipu6_device *isp = pci_get_drvdata(pdev);
+ struct ipu6_mmu *isys_mmu = isp->isys->mmu;
+ struct ipu6_mmu *psys_mmu = isp->psys->mmu;
unsigned long dir;
devm_free_irq(&pdev->dev, pdev->irq, isp);
@@ -844,11 +846,9 @@ static void ipu6_pci_remove(struct pci_dev *pdev)
ipu6_cpd_free_pkg_dir(isp->psys);
ipu6_unmap_fw_region(isp->psys, dir);
- if (isp->isys) {
- ipu6_cpd_free_pkg_dir(isp->isys);
- if (isp->isys->fw_sgt.nents)
- ipu6_unmap_fw_region(isp->isys, dir);
- }
+ ipu6_cpd_free_pkg_dir(isp->isys);
+ if (isp->isys->fw_sgt.nents)
+ ipu6_unmap_fw_region(isp->isys, dir);
vfree(isp->fw_code_region);
isp->fw_code_region = NULL;
@@ -862,10 +862,8 @@ static void ipu6_pci_remove(struct pci_dev *pdev)
release_firmware(isp->cpd_fw);
- if (isp->psys)
- ipu6_mmu_cleanup(isp->psys->mmu);
- if (isp->isys)
- ipu6_mmu_cleanup(isp->isys->mmu);
+ ipu6_mmu_cleanup(psys_mmu);
+ ipu6_mmu_cleanup(isys_mmu);
}
static void ipu6_pci_reset_prepare(struct pci_dev *pdev)
--
2.55.0
next reply other threads:[~2026-09-24 12:07 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 12:06 Antti Laakso [this message]
2026-09-24 12:18 ` [PATCH] media: ipu6: Fix bus device use-after-free Sakari Ailus
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=20260924120634.1420687-1-antti.laakso@linux.intel.com \
--to=antti.laakso@linux.intel.com \
--cc=error27@gmail.com \
--cc=linux-media@vger.kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=sarang.sapre@intel.com \
/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