media: stm32: csi: fix async notifier leak and UAF on probe error and remove
Subsystems (3)
PATCH 1/1 media: stm32: csi: fix async notifier leak and UAF on probe error and remove
stm32_csi_parse_dt() registers the V4L2 async notifier with v4l2_async_nf_register(). Two teardown paths fail to undo this:
- The probe error label err_cleanup is only reached after stm32_csi_parse_dt() has succeeded (and thus registered the notifier), but it calls only v4l2_async_nf_cleanup(), never v4l2_async_nf_unregister().
- stm32_csi_remove() unregisters the subdev but never unregisters or cleans up the notifier at all.
In both cases the notifier stays chained in the global notifier_list while the enclosing struct stm32_csi_dev is freed by devres, leading to list corruption and a use-after-free when the list is next walked.
Unregister and clean up the notifier on both paths, matching the required v4l2_async_nf_unregister() + v4l2_async_nf_cleanup() teardown.
--- drivers/media/platform/st/stm32/stm32-csi.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/media/platform/st/stm32/stm32-csi.c +4 -0
@@ -1059,6 +1059,7 @@ static int stm32_csi_probe(struct platform_device *pdev)return 0 ; err_cleanup: +v4l2_async_nf_unregister (&csidev->notifier);v4l2_async_nf_cleanup (&csidev->notifier);return ret; }
@@ -1069,6 +1070,9 @@ static void stm32_csi_remove(struct platform_device *pdev)v4l2_async_unregister_subdev (&csidev->sd); +v4l2_async_nf_unregister (&csidev->notifier); +v4l2_async_nf_cleanup (&csidev->notifier); +pm_runtime_disable (&pdev->dev); }
Signature · 1 line
2.25.1