From patchwork Fri Jul 22 15:51:22 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9243817 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CE05360756 for ; Fri, 22 Jul 2016 15:51:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF15A262FF for ; Fri, 22 Jul 2016 15:51:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B33AC27FA7; Fri, 22 Jul 2016 15:51:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E873262FF for ; Fri, 22 Jul 2016 15:51:40 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7EFDB6EBF3; Fri, 22 Jul 2016 15:51:37 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mout.web.de (mout.web.de [212.227.15.4]) by gabe.freedesktop.org (Postfix) with ESMTPS id 533E36EBF3 for ; Fri, 22 Jul 2016 15:51:34 +0000 (UTC) Received: from [192.168.1.2] ([77.182.75.73]) by smtp.web.de (mrweb002) with ESMTPSA (Nemesis) id 0LfAfQ-1ayDqt2oOm-00okSC; Fri, 22 Jul 2016 17:51:23 +0200 Subject: [PATCH 4/4] GPU-DRM-Etnaviv: Optimize error handling in etnaviv_gem_new_userptr() To: dri-devel@lists.freedesktop.org, Christian Gmeiner , David Airlie , Lucas Stach , Russell King References: <5307CAA2.8060406@users.sourceforge.net> <530A086E.8010901@users.sourceforge.net> <530A72AA.3000601@users.sourceforge.net> <530B5FB6.6010207@users.sourceforge.net> <530C5E18.1020800@users.sourceforge.net> <530CD2C4.4050903@users.sourceforge.net> <530CF8FF.8080600@users.sourceforge.net> <530DD06F.4090703@users.sourceforge.net> <5317A59D.4@users.sourceforge.net> <00ca5af9-674a-73ce-b423-1ce41d426942@users.sourceforge.net> From: SF Markus Elfring Message-ID: <4af34ce6-62c6-7966-1ae3-0877d5ac909d@users.sourceforge.net> Date: Fri, 22 Jul 2016 17:51:22 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 MIME-Version: 1.0 In-Reply-To: <00ca5af9-674a-73ce-b423-1ce41d426942@users.sourceforge.net> X-Provags-ID: V03:K0:F83oOdgQeKNk45Kjothdks9dl9T/Q51b1x2uZL/FHoOfKWgTfVw N3FDhNJdYAS+JIPyPKNZf1JGq8GVckuILYgBgrBS79fhKFpNxiWQKbD1U1D72vPhLQQ6wEq R7ailchYpwCKUFVmFsh4UxOGP1gCpiaap1mMOm36M04ql7ZKFGRjFu5NdcUnpnXBuGvuHyT U8P01Ng8GR9aPGvTEHrFw== X-UI-Out-Filterresults: notjunk:1; V01:K0:qKzvQ7Yp96A=:ErlcxqJEFVv/GaNgTOh7k6 aj9yGRFalHEpxKF7UdnbYEMiATjbErIjUC7R73hqrIOiVLc2whhvMMfXcD0mgF/2oPncnEUYc Z/fHbqTFOhh+zhSU60sZNUq13AGw/21F0Qs/8nRT0VU7++38S8KwUkWPKjM8XSU+Bwex9RXcp zS7hGBxFWQB4J2YyMxvHeoyZUovfUseBZLWIpjaDqmwc9mQRqzRXdbPGEr7sv9cC6qmIG9WrP KXRpEEnf9zxA4flJjYWrIVI0UhMkqghlE0/xqfoWOKp6ALlkU+/dm/NTCEdQmkPFzLurwH/0y P2g/Ohbp5ZIdBUV/u5PIhu7Hw+fdHpr6PLpi9cScktAg45M8M8vjiB3u4r/4PvjSztQWY0Y/m K1rJikoOyuc5L+fwRSyamxhA6DtbpAFO3ZH4hRATjRBofxVvupzsZb375hdLRRnd58/uywX38 JN5JLKfEda0unIiCba6fY5eKwYeng4TMtLj6hgNcVExtRDjnLlvBcnlHUD/5+XM2Ov5pI4ffD rCiueVeMW7TeJtVEE9get6HWlgasu4nU6Kpog1zwRLFKWPoBuW47Qxxr/g8NNi/KR/+/vXk9j gAXqMZl1Wu/sN3HHkvTYHRp9O6aMz5tlnUp7OcWBN9SiNpX4VnzI+2d4UBLg6vDNLcHpTgcPG 2bE20Rq6i0a5FTZn93flLi5xrE5M8xzsRiI7tM4QZzQ6ZY68eLutquDYepdDMkU1IIo4Ax2AV n/MDDBJOgALD2lqvGCe17vRfYAR3n5NFwXkulTMkovDP9EWEmO7wd/DrepGeUCQB+NGLDraec +wNvsRQ Cc: Julia Lawall , kernel-janitors@vger.kernel.org, LKML X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring 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 --- 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; }