UPSTREAM: drm/rockchip: don't leak iommu mapping
authorJohn Keeping <john@metanate.com>
Tue, 5 Apr 2016 13:50:32 +0000 (14:50 +0100)
committerHuang, Tao <huangtao@rock-chips.com>
Wed, 7 Dec 2016 06:21:42 +0000 (14:21 +0800)
arm_iommu_attach_device() takes its own reference to the mapping we give
it.  Since we do not keep a reference to the mapping ourselves, we must
release it before returning.

Also fix the error path, which fails to release the mapping if it has
called arm_iommu_detach_device() since that clears archdata.mapping.

Conflicts:
drivers/gpu/drm/rockchip/rockchip_drm_drv.c

Change-Id: Ia20334afbce08ece5a3238a7b0786547ec0cafb2
Signed-off-by: John Keeping <john@metanate.com>
Signed-off-by: Randy Li <randy.li@rock-chips.com>
Signed-off-by: Huang, Tao <huangtao@rock-chips.com>
(cherry picked from commit 69b007968e7519cf1e44920f4578054c9e0fbdc3)

drivers/gpu/drm/rockchip/rockchip_drm_drv.c

index 86382b7965d5b9a26652fc5034dfb5887f13996b..04081b3784dc8a6eee66cafdb76454c294902dc5 100644 (file)
@@ -797,6 +797,7 @@ static int rockchip_drm_load(struct drm_device *drm_dev, unsigned long flags)
 
        drm_dev->mode_config.allow_fb_modifiers = true;
 
 
        drm_dev->mode_config.allow_fb_modifiers = true;
 
+       arm_iommu_release_mapping(mapping);
        return 0;
 err_vblank_cleanup:
        drm_vblank_cleanup(drm_dev);
        return 0;
 err_vblank_cleanup:
        drm_vblank_cleanup(drm_dev);
@@ -807,7 +808,7 @@ err_unbind:
 err_detach_device:
        arm_iommu_detach_device(dev);
 err_release_mapping:
 err_detach_device:
        arm_iommu_detach_device(dev);
 err_release_mapping:
-       arm_iommu_release_mapping(dev->archdata.mapping);
+       arm_iommu_release_mapping(mapping);
 err_config_cleanup:
        drm_mode_config_cleanup(drm_dev);
        drm_dev->dev_private = NULL;
 err_config_cleanup:
        drm_mode_config_cleanup(drm_dev);
        drm_dev->dev_private = NULL;