drm/gem: fix not to assign error value to gem name
Subsystems (2)
PATCH 1/1 drm/gem: fix not to assign error value to gem name
From: YoungJun Cho <[email protected]>
If idr_alloc() is failed, obj->name can be error value. Also it cleans up duplicated flink processing code.
--- drivers/gpu/drm/drm_gem.c | 18 +++++++----------- 1 files changed, 7 insertions(+), 11 deletions(-)
drivers/gpu/drm/drm_gem.c +7 -11
@@ -453,25 +453,21 @@ drm_gem_flink_ioctl(struct drm_device *dev, void *data,spin_lock (&dev->object_name_lock);if (!obj->name) { ret =idr_alloc (&dev->object_name_idr, obj,1 ,0 ,GFP_NOWAIT ); - obj->name = ret; - args->name = (uint64_t ) obj->name; -spin_unlock (&dev->object_name_lock); -idr_preload_end (); -if (ret <0 ) goto err; - ret =0 ; + + obj->name = ret;/* Allocate a reference for the name table. */ drm_gem_object_reference (obj); - }else { - args->name = (uint64_t ) obj->name; -spin_unlock (&dev->object_name_lock); -idr_preload_end (); - ret =0 ; } + args->name = (uint64_t ) obj->name; + ret =0 ; + err: +spin_unlock (&dev->object_name_lock); +idr_preload_end ();drm_gem_object_unreference_unlocked (obj);return ret; }
Signature · 1 line
1.7.4.1
Quoted 4 lines · Seung-Woo Kim
From: YoungJun Cho <[email protected]>
If
idr_alloc()is failed,obj->namecan be error value. Also it cleans up duplicated flink processing code.
You should mention that it is a regression from
commit 2e928815c (drm: convert to idr_alloc())
Quoted 3 lines
Signed-off-by YoungJun Cho <[email protected]>Signed-off-by Seung-Woo Kim <[email protected]>Signed-off-by Kyungmin Park <[email protected]>
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 14 lines · Chris Wilson
Quoted 4 lines · Seung-Woo Kim
From: YoungJun Cho <[email protected]>
If
idr_alloc()is failed,obj->namecan be error value. Also it cleans up duplicated flink processing code.You should mention that it is a regression from
commit2e928815c(drm: convert toidr_alloc())Quoted 3 lines
Signed-off-by YoungJun Cho <[email protected]>Signed-off-by Seung-Woo Kim <[email protected]>Signed-off-by Kyungmin Park <[email protected]>
Quoted 6 lines
Reviewed-by Chris Wilson <[email protected]>-Chris
--
Chris Wilson, Intel Open Source Technology Centre
Thank you for comments!
I'll update commit msg.
Best regards YJ
_______________________________________________
Quoted 3 lines
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 1/1 drm/gem: fix not to assign error value to gem name
In reply to Chris WilsonFrom: YoungJun Cho <[email protected]>
If idr_alloc() is failed, obj->name can be error value. Also it cleans up duplicated flink processing code.
This regression has been introduced in
commit 2e928815c1886fe628ed54623aa98d0889cf5509
Author: Tejun Heo <[email protected]> Date: Wed Feb 27 17:04:08 2013 -0800
drm: convert to idr_alloc()
---
change since v1:
- Add a regression commit information in commit msg as Chris commented
drivers/gpu/drm/drm_gem.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)
drivers/gpu/drm/drm_gem.c +7 -11
@@ -453,25 +453,21 @@ drm_gem_flink_ioctl(struct drm_device *dev, void *data,spin_lock (&dev->object_name_lock);if (!obj->name) { ret =idr_alloc (&dev->object_name_idr, obj,1 ,0 ,GFP_NOWAIT ); - obj->name = ret; - args->name = (uint64_t ) obj->name; -spin_unlock (&dev->object_name_lock); -idr_preload_end (); -if (ret <0 ) goto err; - ret =0 ; + + obj->name = ret;/* Allocate a reference for the name table. */ drm_gem_object_reference (obj); - }else { - args->name = (uint64_t ) obj->name; -spin_unlock (&dev->object_name_lock); -idr_preload_end (); - ret =0 ; } + args->name = (uint64_t ) obj->name; + ret =0 ; + err: +spin_unlock (&dev->object_name_lock); +idr_preload_end ();drm_gem_object_unreference_unlocked (obj);return ret; }
Signature · 1 line
1.7.9.5
Quoted 8 lines · Seung-Woo Kim
From: YoungJun Cho <[email protected]>
If
idr_alloc()is failed,obj->namecan be error value. Also it cleans up duplicated flink processing code.This regression has been introduced in
commit
2e928815c1886fe628ed54623aa98d0889cf5509
Quoted 8 lines
Author: Tejun Heo <[email protected]> Date: Wed Feb 27 17:04:08 2013 -0800drm: convert to
idr_alloc()Signed-off-by YoungJun Cho <[email protected]>Signed-off-by Seung-Woo Kim <[email protected]>Signed-off-by Kyungmin Park <[email protected]>
Minor comment inline.
Quoted 12 lines
---
change since v1:
- Add a regression commit information in commit msg as Chris commenteddrivers/gpu/drm/drm_gem.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)drivers/gpu/drm/drm_gem.c +0
-0
drivers/gpu/drm/drm_gem.c drm_gem_flink_ioctl(struct drm_device *dev, void *data, · line 457
Quoted 10 lines
drivers/gpu/drm/drm_gem.c +0
-5@@ -453,25 +453,21 @@ drm_gem_flink_ioctl(struct drm_device *dev, void *data,spin_lock (&dev->object_name_lock);if (!obj->name) { ret =idr_alloc (&dev->object_name_idr, obj,1 ,0 ,GFP_NOWAIT ); - obj->name = ret; - args->name = (uint64_t ) obj->name; -spin_unlock (&dev->object_name_lock); -idr_preload_end (); -if (ret <0 ) goto err;
Being pedantic, ret == 0 is also an error - but a programming error leading to an object leak. BUG_ON(ret == 0) ?
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Hello, Chris,
Quoted 40 lines · Chris Wilson
Quoted 8 lines · Seung-Woo Kim
From: YoungJun Cho <[email protected]>
If
idr_alloc()is failed,obj->namecan be error value. Also it cleans up duplicated flink processing code.This regression has been introduced in
commit
2e928815c1886fe628ed54623aa98d0889cf5509Quoted 8 lines
Author: Tejun Heo <[email protected]> Date: Wed Feb 27 17:04:08 2013 -0800drm: convert to
idr_alloc()Signed-off-by YoungJun Cho <[email protected]>Signed-off-by Seung-Woo Kim <[email protected]>Signed-off-by Kyungmin Park <[email protected]>Reviewed-by Chris Wilson <[email protected]>Minor comment inline.
Quoted 18 lines
---
change since v1:
- Add a regression commit information in commit msg as Chris commenteddrivers/gpu/drm/drm_gem.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-)drivers/gpu/drm/drm_gem.c +0
-3@@ -453,25 +453,21 @@ drm_gem_flink_ioctl(struct drm_device *dev, void *data,spin_lock (&dev->object_name_lock);if (!obj->name) { ret =idr_alloc (&dev->object_name_idr, obj,1 ,0 ,GFP_NOWAIT ); - obj->name = ret; - args->name = (uint64_t ) obj->name; -spin_unlock (&dev->object_name_lock);
Quoted 9 lines
drivers/gpu/drm/drm_gem.c drm_gem_flink_ioctl(struct drm_device *dev, void *data, · line 457
Quoted 4 lines
drivers/gpu/drm/drm_gem.c +0
-2-idr_preload_end (); -if (ret <0 ) goto err;Being pedantic, ret == 0 is also an error - but a programming error leading to an object leak.
BUG_ON(ret == 0)?
-Chris
It seems that idr_alloc() with start id 1 does not return 0, so IMHO, ret == 0 can be ignored here.
But if you think it needs to consider programming error, I'll add some assertion. Please let me know.
Thanks and Regards,
- Seung-Woo Kim
Signature · 8 lines
Seung-Woo Kim Samsung Software R&D Center -- _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 6 lines · 김승우
Quoted 3 lines
Being pedantic, ret == 0 is also an error - but a programming error leading to an object leak.
BUG_ON(ret == 0)?It seems that
idr_alloc()with start id 1 does not return 0, so IMHO, ret == 0 can be ignored here.
Yes, it is an impossible condition, hence the suggestion of a BUG_ON(). It is a paranoid check for whether idr_alloc() fails.
Quoted 2 lines
But if you think it needs to consider programming error, I'll add some assertion. Please let me know.
Successfully setting obj->name = 0 would lead to interesting confusion in userspace, and very difficult to debug. Given that, maybe it would be better to BUG in the kernel. If you do feel like adding it, submit it as a separate patch, so that it is not caught up with the bugfix. -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel