diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2020-03-23 17:49:12 +0300 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2020-03-26 17:26:51 +0300 |
commit | 363de9e7d4f6b1dd7993f316a064df1f9abc3341 (patch) | |
tree | 66297e66c037d7f92e8e1bcd14f2bbdd1532e303 /drivers/gpu/drm/vgem/vgem_drv.c | |
parent | e2edcaaa3da88018bf6afd4dd09b8b5b4f8e8443 (diff) | |
download | linux-363de9e7d4f6b1dd7993f316a064df1f9abc3341.tar.xz |
drm/vgem: Use drmm_add_final_kfree
With this we can drop the final kfree from the release function.
v2: After drm_dev_init/drmm_add_final_kfree we need to clean up
everything through a drm_dev_put. Rework the unwind code to match
that.
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Emil Velikov <emil.velikov@collabora.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Sean Paul <seanpaul@chromium.org>
Cc: Eric Anholt <eric@anholt.net>
Cc: Rob Clark <robdclark@chromium.org>
Cc: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20200323144950.3018436-14-daniel.vetter@ffwll.ch
Diffstat (limited to 'drivers/gpu/drm/vgem/vgem_drv.c')
-rw-r--r-- | drivers/gpu/drm/vgem/vgem_drv.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/drivers/gpu/drm/vgem/vgem_drv.c b/drivers/gpu/drm/vgem/vgem_drv.c index 909eba43664a..7486014e9149 100644 --- a/drivers/gpu/drm/vgem/vgem_drv.c +++ b/drivers/gpu/drm/vgem/vgem_drv.c @@ -39,6 +39,7 @@ #include <drm/drm_drv.h> #include <drm/drm_file.h> #include <drm/drm_ioctl.h> +#include <drm/drm_managed.h> #include <drm/drm_prime.h> #include "vgem_drv.h" @@ -432,8 +433,6 @@ static void vgem_release(struct drm_device *dev) platform_device_unregister(vgem->platform); drm_dev_fini(&vgem->drm); - - kfree(vgem); } static struct drm_driver vgem_driver = { @@ -489,16 +488,19 @@ static int __init vgem_init(void) &vgem_device->platform->dev); if (ret) goto out_unregister; + drmm_add_final_kfree(&vgem_device->drm, vgem_device); /* Final step: expose the device/driver to userspace */ - ret = drm_dev_register(&vgem_device->drm, 0); + ret = drm_dev_register(&vgem_device->drm, 0); if (ret) - goto out_fini; + goto out_put; return 0; -out_fini: - drm_dev_fini(&vgem_device->drm); +out_put: + drm_dev_put(&vgem_device->drm); + return ret; + out_unregister: platform_device_unregister(vgem_device->platform); out_free: |