diff mbox

[4/4] GPU-DRM-Etnaviv: Optimize error handling in etnaviv_gem_new_userptr()

Message ID 4af34ce6-62c6-7966-1ae3-0877d5ac909d@users.sourceforge.net (mailing list archive)
State New, archived
Headers show

Commit Message

SF Markus Elfring July 22, 2016, 3:51 p.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Fri, 22 Jul 2016 17:17:48 +0200

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 <elfring@users.sourceforge.net>
---
 drivers/gpu/drm/etnaviv/etnaviv_gem.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

Comments

Sean Paul July 22, 2016, 5:54 p.m. UTC | #1
On Fri, Jul 22, 2016 at 11:51 AM, SF Markus Elfring
<elfring@users.sourceforge.net> wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Fri, 22 Jul 2016 17:17:48 +0200
>
> 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 <elfring@users.sourceforge.net>

Applied to drm-misc. In the future, could you please format your
subjects starting with "drm/<driver>"? I've fixed this one and the
first, but it'd be nice not to have to do that going forward.

Sean

> ---
>  drivers/gpu/drm/etnaviv/etnaviv_gem.c | 9 +++------
>  1 file changed, 3 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
> index 0a5c00c..007577c 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
> @@ -909,15 +909,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;
>  }
> --
> 2.9.2
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox

Patch

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem.c b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
index 0a5c00c..007577c 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem.c
@@ -909,15 +909,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;
 }