Commit 3e49c4f4 authored by Chris Wilson's avatar Chris Wilson Committed by Dave Airlie

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: default avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarEric Anholt <eric@anholt.net>
Signed-off-by: default avatarDave Airlie <airlied@linux.ie>
parent ad45aa9e
...@@ -295,8 +295,10 @@ drm_gem_flink_ioctl(struct drm_device *dev, void *data, ...@@ -295,8 +295,10 @@ drm_gem_flink_ioctl(struct drm_device *dev, void *data,
return -EBADF; return -EBADF;
again: again:
if (idr_pre_get(&dev->object_name_idr, GFP_KERNEL) == 0) if (idr_pre_get(&dev->object_name_idr, GFP_KERNEL) == 0) {
return -ENOMEM; ret = -ENOMEM;
goto err;
}
spin_lock(&dev->object_name_lock); spin_lock(&dev->object_name_lock);
if (obj->name) { if (obj->name) {
...@@ -310,12 +312,8 @@ again: ...@@ -310,12 +312,8 @@ again:
if (ret == -EAGAIN) if (ret == -EAGAIN)
goto again; goto again;
if (ret != 0) { if (ret != 0)
mutex_lock(&dev->struct_mutex); goto err;
drm_gem_object_unreference(obj);
mutex_unlock(&dev->struct_mutex);
return ret;
}
/* /*
* Leave the reference from the lookup around as the * Leave the reference from the lookup around as the
...@@ -324,6 +322,12 @@ again: ...@@ -324,6 +322,12 @@ again:
args->name = (uint64_t) obj->name; args->name = (uint64_t) obj->name;
return 0; return 0;
err:
mutex_lock(&dev->struct_mutex);
drm_gem_object_unreference(obj);
mutex_unlock(&dev->struct_mutex);
return ret;
} }
/** /**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment