media: ti: vpe: fix double free after video device registration failure
Subsystems (2)
PATCH 1/1 media: ti: vpe: fix double free after video device registration failure
vpe_fw_cb() is called asynchronously by vpe_probe().
If video_register_device() fails there, all the cleanup functions are called. The driver stays bound, so vpe_remove() later does all of this again, freeing dev->m2m_dev a second time.
Leave the cleanup to vpe_remove().
This bug was found statically and is theoretical.
--- drivers/media/platform/ti/vpe/vpe.c | 6 ------ 1 file changed, 6 deletions(-)
drivers/media/platform/ti/vpe/vpe.c +0 -6
@@ -2496,12 +2496,6 @@ static void vpe_fw_cb(struct platform_device *pdev)if (ret) {vpe_err (dev,"Failed to register video device\n" ); -vpe_set_clock_enable (dev,0 ); -vpe_runtime_put (pdev); -pm_runtime_disable (&pdev->dev); -v4l2_m2m_release (dev->m2m_dev); -v4l2_device_unregister (&dev->v4l2_dev); -return ; }
Signature · 1 line
2.53.0
Hi Thomas,
Thanks for the patch.
Quoted 27 lines · Thomas Fourier
vpe_fw_cb()is called asynchronously byvpe_probe().
Ifvideo_register_device()fails there, all the cleanup functions are called. The driver stays bound, sovpe_remove()later does all of this
again, freeingdev->m2m_deva second time.Leave the cleanup to
vpe_remove().This bug was found statically and is theoretical.
Signed-off-by Thomas Fourier <[email protected]>Fixes b2c9472f0559 ("[media] v4l: ti-vpe: register video device onlywhen firmware is loaded")
---
drivers/media/platform/ti/vpe/vpe.c | 6 ------1 file changed, 6 deletions(-)drivers/media/platform/ti/vpe/vpe.c +0
-0@@ -2496,12 +2496,6 @@ static void vpe_fw_cb(struct platform_device *pdev) if (ret) { vpe_err(dev, "Failed to register video device\n");
Quoted 9 lines
- vpe_set_clock_enable(dev, 0); - vpe_runtime_put(pdev);
- pm_runtime_disable(&pdev->dev); - v4l2_m2m_release(dev->m2m_dev); - v4l2_device_unregister(&dev->v4l2_dev); -
return;
}
I analysed the driver, and the fix seems correct. Hence,
Thanks and Regards,
Yemike Abhilash Chandra