Skip to contentSkip to conversation

media: intel/ipu6: fix error pointer dereference

PATCH Superseded Ethan Tidmore 2 participants 2 messages Feb 17 – Mar 2

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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

After confirming that isp->psys is an error pointer goto is called and imminently goes to this code snippet below:

out_ipu6_bus_del_devices:

	if (isp->psys) {
		ipu6_cpd_free_pkg_dir(isp->psys);
		ipu6_buttress_unmap_fw_image(isp->psys, &isp->psys->fw_sgt);
	}

Since isp->psys is confirmed to be an error pointer not NULL, the condition is true and the error pointer is dereferenced. So isp->psys should be set to NULL before going to out_ipu6_bus_del_devices.

Fixes 25fedc021985a ("media: intel/ipu6: add Intel IPU6 PCI device driver")
---
 drivers/media/pci/intel/ipu6/ipu6.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/pci/intel/ipu6/ipu6.c +1 -0
index 24238f8311a6..6e6b7d2a68ff 100644
@@ -619,6 +619,7 @@ static int ipu6_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 				   psys_base, &psys_ipdata);
 	if (IS_ERR(isp->psys)) {
 		ret = PTR_ERR(isp->psys);
+		isp->psys = NULL;
 		goto out_ipu6_bus_del_devices;
 	}
 
Signature · 1 line
2.53.0
maintainer
#1 lore raw

Hi Ethan,

Thanks for the patch.

Quoted 9 lines · Ethan Tidmore

After confirming that isp->psys is an error pointer goto is called and imminently goes to this code snippet below:

out_ipu6_bus_del_devices:

	if (isp->psys) {
		ipu6_cpd_free_pkg_dir(isp->psys);
		ipu6_buttress_unmap_fw_image(isp->psys, &isp->psys->fw_sgt);
	}
Quoted 5 lines

Since isp->psys is confirmed to be an error pointer not NULL, the condition is true and the error pointer is dereferenced. So isp->psys should be set to NULL before going to out_ipu6_bus_del_devices.

Fixes 25fedc021985a ("media: intel/ipu6: add Intel IPU6 PCI device driver")

Add:

Quoted 10 lines
---
 drivers/media/pci/intel/ipu6/ipu6.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/pci/intel/ipu6/ipu6.c +0 -0
index 24238f8311a6..6e6b7d2a68ff 100644

drivers/media/pci/intel/ipu6/ipu6.c static int ipu6_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) · line 622

Quoted 4 lines
drivers/media/pci/intel/ipu6/ipu6.c +1 -0
@@ -619,6 +619,7 @@ static int ipu6_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 				   psys_base, &psys_ipdata);
 	if (IS_ERR(isp->psys)) {
 		ret = PTR_ERR(isp->psys);
+		isp->psys = NULL;

There are a number of checks for IS_ERR_OR_NULL() in error handling; instead of setting psys to NULL here I'd add the same test to the condition after out_ipu6_bus_del_devices:.

Quoted 3 lines
drivers/media/pci/intel/ipu6/ipu6.c +0 -0
 		goto out_ipu6_bus_del_devices;
 	}
 
Signature · 3 lines
Kind regards,

Sakari Ailus