On Sat Jul 18 14:10:11 2026 +0800, Guangshuo Li wrote:
> saa7164_dev_setup() adds the device to the global saa7164_devlist before
> requesting the PCI BAR memory regions.
> 
> If get_resources() fails, saa7164_dev_setup() decrements the device count
> and returns an error, but leaves the device on saa7164_devlist. The probe
> error path then frees the device, leaving a dangling entry on the global
> list.
> 
> Reuse the existing MMIO mapping error path to remove the device from
> saa7164_devlist and decrement the device count before returning.
> 
> Also release BAR0 if it was successfully requested but the BAR2 request
> fails.
> 
> Fixes: 443c1228d505 ("V4L/DVB (12923): SAA7164: Add support for the NXP 
> SAA7164 silicon")
> Cc: [email protected]
> Signed-off-by: Guangshuo Li <[email protected]>
> Signed-off-by: Hans Verkuil <[email protected]>

Patch committed.

Thanks,
Hans Verkuil

 drivers/media/pci/saa7164/saa7164-core.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

---

diff --git a/drivers/media/pci/saa7164/saa7164-core.c 
b/drivers/media/pci/saa7164/saa7164-core.c
index 683bd78288b3..ac5eb6b923e2 100644
--- a/drivers/media/pci/saa7164/saa7164-core.c
+++ b/drivers/media/pci/saa7164/saa7164-core.c
@@ -878,6 +878,9 @@ static int get_resources(struct saa7164_dev *dev)
                if (request_mem_region(pci_resource_start(dev->pci, 2),
                        pci_resource_len(dev->pci, 2), dev->name))
                        return 0;
+
+               release_mem_region(pci_resource_start(dev->pci, 0),
+                                  pci_resource_len(dev->pci, 0));
        }
 
        printk(KERN_ERR "%s: can't get MMIO memory @ 0x%llx or 0x%llx\n",
@@ -1000,8 +1003,7 @@ static int saa7164_dev_setup(struct saa7164_dev *dev)
                       dev->name, dev->pci->subsystem_vendor,
                       dev->pci->subsystem_device);
 
-               saa7164_devcount--;
-               return -ENODEV;
+               goto err_devlist;
        }
 
        /* PCI/e allocations */
@@ -1039,7 +1041,7 @@ err_ioremap_bar2:
        iounmap(dev->lmmio);
 err_ioremap_bar0:
        release_resources(dev);
-
+err_devlist:
        scoped_guard(mutex, &devlist) {
                list_del(&dev->devlist);
        }
_______________________________________________
linuxtv-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to