Skip to contentSkip to conversation

serial: icom: Disable the PCI device on final adapter release

PATCH In review Myeonghun Pak 3 participants 3 messages Sep 15 – Sep 23

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

PATCH 1/1 serial: icom: Disable the PCI device on final adapter release

icom_probe() enables the PCI device, but the final adapter release never disables it. Balance the enable after releasing the IRQ, mapping and PCI regions, while the adapter's PCI device pointer is still valid.

The imbalance is already present in the initial Git import.

This issue was identified during our ongoing static-analysis research while reviewing kernel code.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
Assisted-by LLM
---
 drivers/tty/serial/icom.c | 1 +
 1 file changed, 1 insertion(+)
drivers/tty/serial/icom.c +1 -0
@@ -1691,6 +1691,7 @@ static void icom_kref_release(struct kref *kref)
 	free_irq(icom_adapter->pci_dev->irq, (void *) icom_adapter);
 	iounmap(icom_adapter->base_addr);
 	pci_release_regions(icom_adapter->pci_dev);
+	pci_disable_device(icom_adapter->pci_dev);
 	icom_free_adapter(icom_adapter);
 }
 
#1 lore raw
Sashiko has reviewed this patch and found no issues. It looks great!
Quoted 9 lines

icom_probe() enables the PCI device, but the final adapter release never disables it. Balance the enable after releasing the IRQ, mapping and PCI regions, while the adapter's PCI device pointer is still valid.

The imbalance is already present in the initial Git import.

This issue was identified during our ongoing static-analysis research while reviewing kernel code.

Quoted 6 lines
Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
Assisted-by LLM

Sashiko has reviewed this patch and found no issues. It looks great!

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
#2 lore raw
In reply to Myeonghun Pak
Quoted 23 lines · Myeonghun Pak

icom_probe() enables the PCI device, but the final adapter release never disables it. Balance the enable after releasing the IRQ, mapping and PCI regions, while the adapter's PCI device pointer is still valid.

The imbalance is already present in the initial Git import.

This issue was identified during our ongoing static-analysis research while reviewing kernel code.

Fixes 1da177e4c3f4 ("Linux-2.6.12-rc2")
Assisted-by LLM
---
 drivers/tty/serial/icom.c | 1 +
 1 file changed, 1 insertion(+)

drivers/tty/serial/icom.c static void icom_kref_release(struct kref *kref) · line 1694

Quoted 4 lines
drivers/tty/serial/icom.c +1 -0
@@ -1691,6 +1691,7 @@ static void icom_kref_release(struct kref *kref)
 	free_irq(icom_adapter->pci_dev->irq, (void *) icom_adapter);
 	iounmap(icom_adapter->base_addr);
 	pci_release_regions(icom_adapter->pci_dev);
+	pci_disable_device(icom_adapter->pci_dev);

Are you sure this is correct? Lots of time disabling the device is not what you want to do as it can cause hardware problems.

Have you tested this on the hardware? If not, I can't take it for obvious reasons.

thanks,

greg k-h