diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2009-02-09 06:31:41 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2009-02-19 21:21:08 -0500 |
commit | 3e49c4f4cf786b70bbc369b99e590de4bebac1b3 (patch) | |
tree | 4805b8adb31570573983c098dd11c307c21381ab /drivers/gpu | |
parent | ad45aa9e6e010283bbd8cf0c6309866233e113f2 (diff) |
drm: Free the object ref on error.
Ensure that the object is unreferenced if we fail to allocate during
drm_gem_flink_ioctl().
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/drm_gem.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c index 308fe1e207f5..e5a8ebf9a662 100644 --- a/drivers/gpu/drm/drm_gem.c +++ b/drivers/gpu/drm/drm_gem.c | |||
@@ -295,8 +295,10 @@ drm_gem_flink_ioctl(struct drm_device *dev, void *data, | |||
295 | return -EBADF; | 295 | return -EBADF; |
296 | 296 | ||
297 | again: | 297 | again: |
298 | if (idr_pre_get(&dev->object_name_idr, GFP_KERNEL) == 0) | 298 | if (idr_pre_get(&dev->object_name_idr, GFP_KERNEL) == 0) { |
299 | return -ENOMEM; | 299 | ret = -ENOMEM; |
300 | goto err; | ||
301 | } | ||
300 | 302 | ||
301 | spin_lock(&dev->object_name_lock); | 303 | spin_lock(&dev->object_name_lock); |
302 | if (obj->name) { | 304 | if (obj->name) { |
@@ -310,12 +312,8 @@ again: | |||
310 | if (ret == -EAGAIN) | 312 | if (ret == -EAGAIN) |
311 | goto again; | 313 | goto again; |
312 | 314 | ||
313 | if (ret != 0) { | 315 | if (ret != 0) |
314 | mutex_lock(&dev->struct_mutex); | 316 | goto err; |
315 | drm_gem_object_unreference(obj); | ||
316 | mutex_unlock(&dev->struct_mutex); | ||
317 | return ret; | ||
318 | } | ||
319 | 317 | ||
320 | /* | 318 | /* |
321 | * Leave the reference from the lookup around as the | 319 | * Leave the reference from the lookup around as the |
@@ -324,6 +322,12 @@ again: | |||
324 | args->name = (uint64_t) obj->name; | 322 | args->name = (uint64_t) obj->name; |
325 | 323 | ||
326 | return 0; | 324 | return 0; |
325 | |||
326 | err: | ||
327 | mutex_lock(&dev->struct_mutex); | ||
328 | drm_gem_object_unreference(obj); | ||
329 | mutex_unlock(&dev->struct_mutex); | ||
330 | return ret; | ||
327 | } | 331 | } |
328 | 332 | ||
329 | /** | 333 | /** |