Skip to contentSkip to conversation

media: ddbridge: Disable PCI device on early probe failures

PATCH New Myeonghun Pak 1 participant 1 message Sep 14

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

PATCH 1/1 media: ddbridge: Disable PCI device on early probe failures

The DMA mask and device allocation failure paths return directly after pci_enable_device(), leaving its enable count unbalanced.

Route both failures to the existing PCI disable step, after the cleanup that requires an allocated device object. Preserve the existing error codes and successful probe and removal behavior.

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

Fixes ccad04578fcb ("[media] ddbridge: Initial check-in")
Fixes 22e743898dcd ("media: ddbridge: bump ddbridge code to version 0.9.29")
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/ddbridge/ddbridge-main.c +9 -4
index 248ace2..591a43e 100644
@@ -172,12 +172,16 @@ static int ddb_probe(struct pci_dev *pdev,
 	pci_set_master(pdev);
 
 	if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)))
-		if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(32)))
-			return -ENODEV;
+		if (dma_set_mask(&pdev->dev, DMA_BIT_MASK(32))) {
+			stat = -ENODEV;
+			goto fail_disable_device;
+		}
 
 	dev = vzalloc(sizeof(*dev));
-	if (!dev)
-		return -ENOMEM;
+	if (!dev) {
+		stat = -ENOMEM;
+		goto fail_disable_device;
+	}
 
 	mutex_init(&dev->mutex);
 	dev->has_dma = 1;
@@ -237,6 +241,7 @@ fail:
 
 	ddb_unmap(dev);
 	pci_set_drvdata(pdev, NULL);
+fail_disable_device:
 	pci_disable_device(pdev);
 	return stat;
 }