Skip to contentSkip to conversation

media: mediatek: vpu: release reserved memory on remove

PATCH In review Guangshuo Li 2 participants 2 messages Sep 15 – Sep 29

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: mediatek: vpu: release reserved memory on remove

mtk_vpu_probe() may assign a reserved memory region to the VPU device with of_reserved_mem_device_init(). The probe failure path releases the assignment with of_reserved_mem_device_release(), but the normal remove path does not perform the corresponding cleanup.

As a result, removing the VPU driver after a successful probe can leave the reserved memory assignment associated with the device after its lifetime has ended.

Release the reserved memory assignment after freeing the VPU external firmware memory, matching the cleanup performed by the probe failure path.

This issue was found by manual code inspection.

Fixes 3003a180ef6b ("[media] VPU: mediatek: support Mediatek VPU")
---
 drivers/media/platform/mediatek/vpu/mtk_vpu.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/platform/mediatek/vpu/mtk_vpu.c +1 -0
index 8d8319f0cd22..16b5bdc2f2c0 100644
@@ -966,6 +966,7 @@ static void mtk_vpu_remove(struct platform_device *pdev)
 		destroy_workqueue(vpu->wdt.wq);
 	vpu_free_ext_mem(vpu, P_FW);
 	vpu_free_ext_mem(vpu, D_FW);
+	of_reserved_mem_device_release(&pdev->dev);
 	mutex_destroy(&vpu->vpu_mutex);
 	clk_unprepare(vpu->clk);
 }
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw

Le mardi 15 septembre 2026 à 20:10 +0800, Guangshuo Li a écrit :

Quoted 13 lines

mtk_vpu_probe() may assign a reserved memory region to the VPU device with of_reserved_mem_device_init(). The probe failure path releases the assignment with of_reserved_mem_device_release(), but the normal remove path does not perform the corresponding cleanup.

As a result, removing the VPU driver after a successful probe can leave the reserved memory assignment associated with the device after its lifetime has ended.

Release the reserved memory assignment after freeing the VPU external firmware memory, matching the cleanup performed by the probe failure path.

Quoted 5 lines

This issue was found by manual code inspection.

Fixes 3003a180ef6b ("[media] VPU: mediatek: support Mediatek VPU")
Quoted 16 lines
---
 drivers/media/platform/mediatek/vpu/mtk_vpu.c | 1 +
 1 file changed, 1 insertion(+)
drivers/media/platform/mediatek/vpu/mtk_vpu.c +1 -0
index 8d8319f0cd22..16b5bdc2f2c0 100644
@@ -966,6 +966,7 @@ static void mtk_vpu_remove(struct platform_device *pdev)
 		destroy_workqueue(vpu->wdt.wq);
 	vpu_free_ext_mem(vpu, P_FW);
 	vpu_free_ext_mem(vpu, D_FW);
+	of_reserved_mem_device_release(&pdev->dev);
 	mutex_destroy(&vpu->vpu_mutex);
 	clk_unprepare(vpu->clk);
 }