From: Markus Elfring Date: Fri, 22 Jul 2016 15:17:48 +0000 (+0200) Subject: drm/etnaviv: Optimize error handling in etnaviv_gem_new_userptr() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=d9a7ed770f9d06b998172e4e71791c81476de88f;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git drm/etnaviv: Optimize error handling in etnaviv_gem_new_userptr() Refactor this function implementation so that the drm_gem_object_unreference_unlocked() function will only be called once in case of a failure according to the Linux coding style recommendation for centralized exiting of functions. Signed-off-by: Markus Elfring [seanpaul tweaked subject] Signed-off-by: Sean Paul Link: http://patchwork.freedesktop.org/patch/msgid/4af34ce6-62c6-7966-1ae3-0877d5ac909d@users.sourceforge.net --- diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c b/drivers/gpu/drm/etnaviv/etnaviv_gem.c index 356056ab63d7..56fb8637bb57 100644 --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c @@ -913,15 +913,12 @@ int etnaviv_gem_new_userptr(struct drm_device *dev, struct drm_file *file, get_task_struct(current); ret = etnaviv_gem_obj_add(dev, &etnaviv_obj->base); - if (ret) { - drm_gem_object_unreference_unlocked(&etnaviv_obj->base); - return ret; - } + if (ret) + goto unreference; ret = drm_gem_handle_create(file, &etnaviv_obj->base, handle); - +unreference: /* drop reference from allocate - handle holds it now */ drm_gem_object_unreference_unlocked(&etnaviv_obj->base); - return ret; }