On Fri Jul 24 10:52:18 2026 +0800, Chen Changcheng wrote:
> In cx8802_register_driver(), when drv->probe(driver) fails (non-zero),
> the allocated cx8802_driver struct is freed neither in the else branch
> nor later in cx8802_unregister_driver() (which only frees entries that
> were added to dev->drvlist on success). Each failed probe leaks the
> driver struct.
> 
> Add kfree(driver) in the else branch to fix the leak.
> 
> Signed-off-by: Chen Changcheng <[email protected]>
> Signed-off-by: Hans Verkuil <[email protected]>

Patch committed.

Thanks,
Hans Verkuil

 drivers/media/pci/cx88/cx88-mpeg.c | 1 +
 1 file changed, 1 insertion(+)

---

diff --git a/drivers/media/pci/cx88/cx88-mpeg.c 
b/drivers/media/pci/cx88/cx88-mpeg.c
index a399a9bf3b92..0c07ad335799 100644
--- a/drivers/media/pci/cx88/cx88-mpeg.c
+++ b/drivers/media/pci/cx88/cx88-mpeg.c
@@ -640,6 +640,7 @@ int cx8802_register_driver(struct cx8802_driver *drv)
                        list_add_tail(&driver->drvlist, &dev->drvlist);
                } else {
                        pr_err("cx8802 probe failed, err = %d\n", err);
+                       kfree(driver);
                }
                mutex_unlock(&drv->core->lock);
        }
_______________________________________________
linuxtv-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to