media: mali-c55: add missing of_reserved_mem_device_release()
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH v4 1/3 media: mali-c55: add missing of_reserved_mem_device_release()
mali_c55_probe() calls of_reserved_mem_device_init() to associate reserved memory regions with the device. This function allocates a struct rmem_assigned_device and adds it to a global linked list, which must be explicitly released via of_reserved_mem_device_release() — there is no devm variant of this API.
However, neither the probe error paths nor mali_c55_remove() called of_reserved_mem_device_release(). Any probe failure after the of_reserved_mem_device_init() call, as well as every normal device removal, leaked the reserved memory association on the global list.
Fix this by adding an err_release_mem label at the end of the probe error chain and calling of_reserved_mem_device_release() in mali_c55_remove(). The remove teardown order is also corrected to call mali_c55_media_frameworks_deinit() before kfree(), mirroring the probe init order in reverse.
--- drivers/media/platform/arm/mali-c55/mali-c55-core.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
drivers/media/platform/arm/mali-c55/mali-c55-core.c +8 -3
@@ -806,8 +806,10 @@ static int mali_c55_probe(struct platform_device *pdev)vb2_dma_contig_set_max_seg_size (dev,UINT_MAX ); ret =__mali_c55_power_on (mali_c55); -if (ret) -return dev_err_probe (dev, ret,"failed to power on\n" ); +if (ret) { +dev_err_probe (dev, ret,"failed to power on\n" ); + goto err_release_mem; + } ret =mali_c55_check_hwcfg (mali_c55);if (ret)
@@ -846,6 +848,8 @@ static int mali_c55_probe(struct platform_device *pdev)kfree (mali_c55->context.registers); err_power_off:__mali_c55_power_off (mali_c55); +err_release_mem: +of_reserved_mem_device_release (dev);return ret; }
@@ -854,8 +858,9 @@ static void mali_c55_remove(struct platform_device *pdev) {struct mali_c55 *mali_c55 =platform_get_drvdata (pdev); -kfree (mali_c55->context.registers);mali_c55_media_frameworks_deinit (mali_c55); +kfree (mali_c55->context.registers); +of_reserved_mem_device_release (&pdev->dev); }static const struct of_device_id mali_c55_of_match[] = {
Signature · 1 line
2.53.0
Jacopo Mondi
maintainerHi David
Quoted 17 lines · David Carlier
mali_c55_probe()callsof_reserved_mem_device_init()to associate reserved memory regions with the device. This function allocates a structrmem_assigned_deviceand adds it to a global linked list, which must be explicitly released viaof_reserved_mem_device_release()— there is no devm variant of this API.However, neither the probe error paths nor
mali_c55_remove()calledof_reserved_mem_device_release(). Any probe failure after theof_reserved_mem_device_init()call, as well as every normal device removal, leaked the reserved memory association on the global list.Fix this by adding an
err_release_memlabel at the end of the probe error chain and callingof_reserved_mem_device_release()inmali_c55_remove(). The remove teardown order is also corrected to callmali_c55_media_frameworks_deinit()beforekfree(), mirroring the probe init order in reverse.
Quoted 3 lines
Fixes d5f281f3dd29 ("media: mali-c55: Add Mali-C55 ISP driver")Signed-off-by David Carlier <[email protected]>Reviewed-by Jacopo Mondi <[email protected]>
Please don't send single patches broken out from the series they belong to. Either resend the whole series, or, if really really necessary, just update the single patch in reply to the one in the list by making it [PATCH v4.1] in example.
Otherwise for maintainers knowing what patches to pick up and from where it's quite difficult.
In this case, no need to resend, I'll add my tag (and possibily captialize the first letter of the commit title) once I'll send a pull request for v7.2 (unless Hans still have space to pick these ups for v7.1, I've put him on cc)
Thanks
j
Quoted 44 lines
--- drivers/media/platform/arm/mali-c55/mali-c55-core.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)drivers/media/platform/arm/mali-c55/mali-c55-core.c +8
-4@@ -806,8 +806,10 @@ static int mali_c55_probe(struct platform_device *pdev)vb2_dma_contig_set_max_seg_size (dev,UINT_MAX ); ret =__mali_c55_power_on (mali_c55); -if (ret) -return dev_err_probe (dev, ret,"failed to power on\n" ); +if (ret) { +dev_err_probe (dev, ret,"failed to power on\n" ); + goto err_release_mem; + } ret =mali_c55_check_hwcfg (mali_c55);if (ret)@@ -846,6 +848,8 @@ static int mali_c55_probe(struct platform_device *pdev)kfree (mali_c55->context.registers); err_power_off:__mali_c55_power_off (mali_c55); +err_release_mem: +of_reserved_mem_device_release (dev);return ret; }@@ -854,8 +858,9 @@ static void mali_c55_remove(struct platform_device *pdev) {struct mali_c55 *mali_c55 =platform_get_drvdata (pdev); -kfree (mali_c55->context.registers);mali_c55_media_frameworks_deinit (mali_c55); +kfree (mali_c55->context.registers); +of_reserved_mem_device_release (&pdev->dev); }static const struct of_device_id mali_c55_of_match[] = { --2.53.0