mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] media: ddbridge: Disable PCI device on early probe failures
@ 2026-09-14  1:37 Myeonghun Pak
  0 siblings, 0 replies; only message in thread
From: Myeonghun Pak @ 2026-09-14  1:37 UTC (permalink / raw)
  To: Mauro Carvalho Chehab
  Cc: Oliver Endriss, Ralph Metzler, Daniel Scheller, linux-media,
	linux-kernel, Ijae Kim

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@gmail.com>
Signed-off-by: Ijae Kim <ae878000@gmail.com>
Signed-off-by: Myeonghun Pak <mhun512@gmail.com>
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;
 }

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-09-14  1:37 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-14  1:37 [PATCH] media: ddbridge: Disable PCI device on early probe failures Myeonghun Pak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®