Skip to contentSkip to conversation

media: cx88: Disable PCI device on MPEG initialization failure

PATCH New Myeonghun Pak 1 participant 1 message Sep 14

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

PATCH 1/1 media: cx88: Disable PCI device on MPEG initialization failure

cx8802_init_common() enables the PCI device, then returns directly if DMA mask setup or IRQ registration fails. cx8802_probe() frees the device and drops the shared core reference without disabling PCI.

Disable the PCI device on both post-enable failures. Preserve -EIO for a DMA mask failure and the original request_irq() error. Do not call the full fini helper because the IRQ was not successfully requested. The successful probe and normal removal paths are unchanged.

These missing error-path disables are 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 OpenAI:GPT-5.6

---
Validated with an ARM64 W=1 object build and strict checkpatch. No hardware runtime or probe-failure injection testing was performed.

 drivers/media/pci/cx88/cx88-mpeg.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/media/pci/cx88/cx88-mpeg.c +7 -2
index 0c07ad3..cd23667 100644
@@ -392,7 +392,8 @@ static int cx8802_init_common(struct cx8802_dev *dev)
 	err = dma_set_mask(&dev->pci->dev, DMA_BIT_MASK(32));
 	if (err) {
 		pr_err("Oops: no 32bit PCI DMA ???\n");
-		return -EIO;
+		err = -EIO;
+		goto fail_disable_device;
 	}
 
 	dev->pci_rev = dev->pci->revision;
@@ -413,13 +414,17 @@ static int cx8802_init_common(struct cx8802_dev *dev)
 			  IRQF_SHARED, dev->core->name, dev);
 	if (err < 0) {
 		pr_err("can't get IRQ %d\n", dev->pci->irq);
-		return err;
+		goto fail_disable_device;
 	}
 	cx_set(MO_PCI_INTMSK, core->pci_irqmask);
 
 	/* everything worked */
 	pci_set_drvdata(dev->pci, dev);
 	return 0;
+
+fail_disable_device:
+	pci_disable_device(dev->pci);
+	return err;
 }
 
 static void cx8802_fini_common(struct cx8802_dev *dev)