[PATCH] media: ddbridge: Disable PCI device on early probe failures
From: Myeonghun Pak
Date: Sun Sep 13 2026 - 21:39:04 EST
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")
Co-developed-by: Ijae Kim <ae878000@xxxxxxxxx>
Signed-off-by: Ijae Kim <ae878000@xxxxxxxxx>
Signed-off-by: Myeonghun Pak <mhun512@xxxxxxxxx>
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.
diff --git a/drivers/media/pci/ddbridge/ddbridge-main.c b/drivers/media/pci/ddbridge/ddbridge-main.c
index 248ace2..591a43e 100644
--- a/drivers/media/pci/ddbridge/ddbridge-main.c
+++ b/drivers/media/pci/ddbridge/ddbridge-main.c
@@ -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;
}