[PATCH v2] media: intel/ipu6: fix error pointer dereference

Ethan Tidmore posted 1 patch 3 weeks, 5 days ago
drivers/media/pci/intel/ipu6/ipu6.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v2] media: intel/ipu6: fix error pointer dereference
Posted by Ethan Tidmore 3 weeks, 5 days ago
In a error path isp->psys is confirmed to be an error pointer not NULL
so this condition is true and the error pointer is dereferenced. So
isp-psys should be set to NULL beforegoing to out_ipu6_bus_del_devices.

Detected by Smatch:
drivers/media/pci/intel/ipu6/ipu6.c:690 ipu6_pci_probe() error:
'isp->psys' dereferencing possible ERR_PTR()

Fixes: 25fedc021985a ("media: intel/ipu6: add Intel IPU6 PCI device driver")
Cc: stable@vger.kernel.org
Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
---
v2:
- Add stable tag.
- Add check for null instead of setting isp->psys to NULL.
- Add Smatch warning.

 drivers/media/pci/intel/ipu6/ipu6.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/intel/ipu6/ipu6.c b/drivers/media/pci/intel/ipu6/ipu6.c
index 34f67f4f1bb5..d033d4618169 100644
--- a/drivers/media/pci/intel/ipu6/ipu6.c
+++ b/drivers/media/pci/intel/ipu6/ipu6.c
@@ -686,7 +686,7 @@ static int ipu6_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 out_ipu6_rpm_put:
 	pm_runtime_put_sync(&isp->psys->auxdev.dev);
 out_ipu6_bus_del_devices:
-	if (isp->psys) {
+	if (!IS_ERR_OR_NULL(isp->psys)) {
 		ipu6_cpd_free_pkg_dir(isp->psys);
 		ipu6_buttress_unmap_fw_image(isp->psys, &isp->psys->fw_sgt);
 	}
-- 
2.53.0
Re: [PATCH v2] media: intel/ipu6: fix error pointer dereference
Posted by Ethan Tidmore 3 weeks, 5 days ago
On Fri Mar 6, 2026 at 9:03 PM CST, Ethan Tidmore wrote:
> In a error path isp->psys is confirmed to be an error pointer not NULL
> so this condition is true and the error pointer is dereferenced. So
> isp-psys should be set to NULL beforegoing to out_ipu6_bus_del_devices.

Just noticed typo "beforegoing", will send v3 correcting this.

Thanks,

ET
Re: [PATCH v2] media: intel/ipu6: fix error pointer dereference
Posted by Sakari Ailus 3 weeks, 3 days ago
Hi Ethan,

On Sat, Mar 07, 2026 at 12:55:14AM -0600, Ethan Tidmore wrote:
> On Fri Mar 6, 2026 at 9:03 PM CST, Ethan Tidmore wrote:
> > In a error path isp->psys is confirmed to be an error pointer not NULL
> > so this condition is true and the error pointer is dereferenced. So
> > isp-psys should be set to NULL beforegoing to out_ipu6_bus_del_devices.
> 
> Just noticed typo "beforegoing", will send v3 correcting this.

No need to; I did that while applying the patch.

Thanks!

-- 
Regards,

Sakari Ailus