drm: Fix object leak in DRM_IOCTL_GEM_CHANGE_HANDLE
Subsystems (4)
PATCH v2 1/1 drm: Fix object leak in DRM_IOCTL_GEM_CHANGE_HANDLE
Add missing drm_gem_object_put() call when drm_gem_object_lookup() successfully returns an object. This fixes a GEM object reference leak that can prevent driver modules from unloading when using prime buffers.
---
Changes between v1 and v2:
- move setting ret value under if branch as suggested in review
- add Cc: stable 6.18+
--- drivers/gpu/drm/drm_gem.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/drm_gem.c +6 -2
@@ -1010,8 +1010,10 @@ int drm_gem_change_handle_ioctl(struct drm_device *dev, void *data,if (!obj)return -ENOENT ; -if (args->handle == args->new_handle) -return 0 ; +if (args->handle == args->new_handle) { + ret =0 ; + goto out; + }mutex_lock (&file_priv->prime.lock);
@@ -1043,6 +1045,8 @@ int drm_gem_change_handle_ioctl(struct drm_device *dev, void *data, out_unlock:mutex_unlock (&file_priv->prime.lock); +out: +drm_gem_object_put (obj);return ret; }
Signature · 1 line
2.43.0
kernel test robot
build botFYI: kernel test robot notices the stable kernel rule is not satisfied.
Hi,
Thanks for your patch.
FYI: kernel test robot notices the stable kernel rule is not satisfied.
The check is based on https://www.kernel.org/doc/html/latest/process/stable-kernel-rules.html#option-1
Rule: add the tag "Cc: [email protected]" in the sign-off area to have the patch automatically included in the stable tree.
Subject: [PATCH v2] drm: Fix object leak in DRM_IOCTL_GEM_CHANGE_HANDLE
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Quoted 5 lines · Karol Wachowski
Add missing
drm_gem_object_put()call whendrm_gem_object_lookup()successfully returns an object. This fixes a GEM object reference leak that can prevent driver modules from unloading when using prime buffers.
Quoted 7 lines
Fixes 53096728b891 ("drm: Add DRM prime interface to reassign GEM handle")Signed-off-by Karol Wachowski <[email protected]>---
Changes between v1 and v2:
- move setting ret value under if branch as suggested in review
- add Cc: stable 6.18+
Oh don't CC the stable list on the review mail directly, just add "CC: [email protected] # 6.18+" to the tags. Greg is going to complain about that :(
With that done Reviewed-by: Christian König <[email protected]> and please push to drm-misc-fixes.
If you don't have commit rights for drm-misc-fixes please ping me and I'm going to push that.
Thanks,
Christian.
Quoted 30 lines
--- drivers/gpu/drm/drm_gem.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/gpu/drm/drm_gem.c +6
-2@@ -1010,8 +1010,10 @@ int drm_gem_change_handle_ioctl(struct drm_device *dev, void *data,if (!obj)return -ENOENT ; -if (args->handle == args->new_handle) -return 0 ; +if (args->handle == args->new_handle) { + ret =0 ; + goto out; + }mutex_lock (&file_priv->prime.lock);@@ -1043,6 +1045,8 @@ int drm_gem_change_handle_ioctl(struct drm_device *dev, void *data, out_unlock:mutex_unlock (&file_priv->prime.lock); +out: +drm_gem_object_put (obj);return ret; }
Quoted 9 lines · Christian König
Quoted 7 lines · Karol Wachowski
Add missing
drm_gem_object_put()call whendrm_gem_object_lookup()successfully returns an object. This fixes a GEM object reference leak that can prevent driver modules from unloading when using prime buffers.Fixes 53096728b891 ("drm: Add DRM prime interface to reassign GEM handle")Signed-off-by Karol Wachowski <[email protected]>
Quoted 6 lines
Quoted 4 lines
---
Changes between v1 and v2:
- move setting ret value under if branch as suggested in review
- add Cc: stable 6.18+Oh don't CC the stable list on the review mail directly, just add "CC: [email protected] # 6.18+" to the tags. Greg is going to complain about that :(
Oops, sorry about that. I've just sent V3 with (hopefully) correctly set
Cc: tag this time.
Quoted 38 lines
With that done Reviewed-by: Christian König <[email protected]> and please push to drm-misc-fixes.
If you don't have commit rights for drm-misc-fixes please ping me and I'm going to push that.
Thanks,
Christian.Quoted 30 lines
--- drivers/gpu/drm/drm_gem.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)drivers/gpu/drm/drm_gem.c +6
-2@@ -1010,8 +1010,10 @@ int drm_gem_change_handle_ioctl(struct drm_device *dev, void *data,if (!obj)return -ENOENT ; -if (args->handle == args->new_handle) -return 0 ; +if (args->handle == args->new_handle) { + ret =0 ; + goto out; + }mutex_lock (&file_priv->prime.lock);@@ -1043,6 +1045,8 @@ int drm_gem_change_handle_ioctl(struct drm_device *dev, void *data, out_unlock:mutex_unlock (&file_priv->prime.lock); +out: +drm_gem_object_put (obj);return ret; }