diff mbox

[04/16] drm/mgag200: Don't unreference when handle creation failed

Message ID 1374066449-21714-5-git-send-email-eich@suse.com (mailing list archive)
State New, archived
Headers show

Commit Message

Egbert Eich July 17, 2013, 1:07 p.m. UTC
drm_gem_handle_create() should not have referenced an object when it's
creation has failed for some reason.

Signed-off-by: Egbert Eich <eich@suse.com>
---
 drivers/gpu/drm/mgag200/mgag200_main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Chris Wilson July 17, 2013, 1:28 p.m. UTC | #1
On Wed, Jul 17, 2013 at 03:07:17PM +0200, Egbert Eich wrote:
> drm_gem_handle_create() should not have referenced an object when it's
> creation has failed for some reason.
> 
> Signed-off-by: Egbert Eich <eich@suse.com>

Nak. The unreference here is to free the locally created resource before
returning the error to the user. In the case of success, the only
reference to the object that then remains is through the new handle.
-Chris
Egbert Eich July 17, 2013, 3:55 p.m. UTC | #2
Chris Wilson writes:
 > On Wed, Jul 17, 2013 at 03:07:17PM +0200, Egbert Eich wrote:
 > > drm_gem_handle_create() should not have referenced an object when it's
 > > creation has failed for some reason.
 > > 
 > > Signed-off-by: Egbert Eich <eich@suse.com>
 > 
 > Nak. The unreference here is to free the locally created resource before
 > returning the error to the user. In the case of success, the only
 > reference to the object that then remains is through the new handle.
 > -Chris

Argh, yeah, you're right. Sorry.

Cheers,
	Egbert.
diff mbox

Patch

diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c b/drivers/gpu/drm/mgag200/mgag200_main.c
index 43ebf8d..d51096c 100644
--- a/drivers/gpu/drm/mgag200/mgag200_main.c
+++ b/drivers/gpu/drm/mgag200/mgag200_main.c
@@ -302,10 +302,11 @@  int mgag200_dumb_create(struct drm_file *file,
 		return ret;
 
 	ret = drm_gem_handle_create(file, gobj, &handle);
-	drm_gem_object_unreference_unlocked(gobj);
 	if (ret)
 		return ret;
 
+	drm_gem_object_unreference_unlocked(gobj);
+
 	args->handle = handle;
 	return 0;
 }