Re: [PATCH] drm/exynos: Fix memory leak and release IOMMU mapping structures

From: Lukasz Luba
Date: Thu Mar 05 2020 - 05:05:13 EST


Hi Marek,

On 3/5/20 7:07 AM, Marek Szyprowski wrote:
Hi Lukasz,

On 04.03.2020 23:00, Lukasz Luba wrote:
There is a memory leak which left some objects not freed. The reference
counter of mapping: 'mapping->kref' was 2 when calling
arm_iommu_detach_device(), so the release_iommu_mapping() won't be called.
Since the old mapping structure is not going to be used any more (because
it is detached and new one attached), call arm_iommu_release_mapping()
to trigger cleanup.

This will break IOMMU support in Exynos DRM if deferred probe happens.
Here is a proper fix:

I forgot about the deferred probe.


https://patchwork.kernel.org/patch/11415715/

The mapping initially created by DMA-mapping framework should be
attached back when Exynos DRM releases the subdev device.


Indeed, as you responded in that thread with the example, there is
more dependencies and attaching back the old mapping will work.

I am going add my reviewed-by to your patch.

Regards,
Lukasz