From: Alfie Varghese <alfievarghese22@gmail.com>
To: sakari.ailus@linux.intel.com, gregkh@linuxfoundation.org
Cc: bingbu.cao@intel.com, linux-media@vger.kernel.org,
linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org,
Alfie Varghese <alfievarghese22@gmail.com>
Subject: [PATCH] staging: media: ipu7: add NULL checks before ipu7_mmu_cleanup() in remove
Date: Mon, 13 Jul 2026 22:51:27 +0530 [thread overview]
Message-ID: <20260713172127.615-1-alfievarghese22@gmail.com> (raw)
ipu7_pci_remove() calls ipu7_mmu_cleanup() on isp->isys->mmu and
isp->psys->mmu without checking whether isys or psys are valid
pointers. If ipu7_pci_probe() partially failed and left isys or psys
as NULL or an error pointer, the remove path will dereference a bad
pointer and crash the kernel.
The probe error cleanup path already guards these calls correctly with
IS_ERR_OR_NULL() checks. Apply the same guards in ipu7_pci_remove().
Signed-off-by: Alfie Varghese <alfievarghese22@gmail.com>
---
drivers/staging/media/ipu7/ipu7.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/media/ipu7/ipu7.c b/drivers/staging/media/ipu7/ipu7.c
index 310e3f24e571..41436f22c684 100644
--- a/drivers/staging/media/ipu7/ipu7.c
+++ b/drivers/staging/media/ipu7/ipu7.c
@@ -2637,8 +2637,10 @@ static void ipu7_pci_remove(struct pci_dev *pdev)
if (!IS_ERR_OR_NULL(isp->fw_code_region))
vfree(isp->fw_code_region);
- ipu7_mmu_cleanup(isp->isys->mmu);
- ipu7_mmu_cleanup(isp->psys->mmu);
+ if (!IS_ERR_OR_NULL(isp->isys) && !IS_ERR_OR_NULL(isp->isys->mmu))
+ ipu7_mmu_cleanup(isp->isys->mmu);
+ if (!IS_ERR_OR_NULL(isp->psys) && !IS_ERR_OR_NULL(isp->psys->mmu))
+ ipu7_mmu_cleanup(isp->psys->mmu);
ipu7_bus_del_devices(pdev);
next reply other threads:[~2026-07-13 17:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-13 17:21 Alfie Varghese [this message]
2026-07-14 7:12 ` [PATCH] staging: media: ipu7: add NULL checks before ipu7_mmu_cleanup() in remove Dan Carpenter
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=20260713172127.615-1-alfievarghese22@gmail.com \
--to=alfievarghese22@gmail.com \
--cc=bingbu.cao@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-staging@lists.linux.dev \
--cc=sakari.ailus@linux.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