Skip to contentSkip to conversation

media: intel/ipu6: fix error pointer dereference

PATCH In review Ethan Tidmore 2 participants 3 messages Mar 7 – Mar 9

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 media: intel/ipu6: fix error pointer dereference

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")

---
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(-)
drivers/media/pci/intel/ipu6/ipu6.c +1 -1
index 34f67f4f1bb5..d033d4618169 100644
@@ -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);
 	}
Signature · 1 line
2.53.0
#1 lore raw
Quoted 3 lines · Ethan Tidmore

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

maintainer
#2 lore raw

Hi Ethan,

Quoted 6 lines · Ethan Tidmore
Quoted 3 lines · Ethan Tidmore

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!

Signature · 3 lines
Regards,

Sakari Ailus