From patchwork Thu Aug 18 19:48:04 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: 9288623 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 5D7A6607FF for ; Thu, 18 Aug 2016 19:48:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 45F2528F5B for ; Thu, 18 Aug 2016 19:48:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3A20928F6D; Thu, 18 Aug 2016 19:48:22 +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]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AC66028F5B for ; Thu, 18 Aug 2016 19:48:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A04876EB1A; Thu, 18 Aug 2016 19:48:20 +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 [217.72.192.78]) by gabe.freedesktop.org (Postfix) with ESMTPS id 77DE76EB1A for ; Thu, 18 Aug 2016 19:48:19 +0000 (UTC) Received: from [192.168.1.3] ([77.182.223.38]) by smtp.web.de (mrweb103) with ESMTPSA (Nemesis) id 0MPYJJ-1bWKYo0MiH-004h3j; Thu, 18 Aug 2016 21:48:15 +0200 Subject: [PATCH 2/2] GPU-DRM-Savage: Less function calls in savage_bci_cmdbuf() after error detection To: "dri-devel@lists.freedesktop.org" , Daniel Vetter , David Airlie References: <566ABCD9.1060404@users.sourceforge.net> <77052ac1-1933-49af-3ad8-6e0eecc1aafe@users.sourceforge.net> From: SF Markus Elfring Message-ID: Date: Thu, 18 Aug 2016 21:48:04 +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: <77052ac1-1933-49af-3ad8-6e0eecc1aafe@users.sourceforge.net> X-Provags-ID: V03:K0:dA2T8JM2zZcHEHVlH8S06zV23V9vaSlE6/P3CIyOWWBmYms6LU5 Fh2n25/vY7Yt7SrffHW+vHXiVqVJsrl2t3zLaAU95pD9uG8cBLfAEmE4dH+bHIoC3cAGETI w6I196zGm2FD148SPUNo1Xjhc44zmttyjyk1aIenAv+zut5xw/2EyonysI/3rrxfnOqMCJq De4X5kRQIFy3qZbqmaQyA== X-UI-Out-Filterresults: notjunk:1; V01:K0:uhcXCQuUwLI=:M+PiHptHWSbQL6kA3ceRIL NCoZD3XHoXFRHSU2ILrqO5QpwqLMbC5okOLmDTRGho60nwTQzDlASIFpQyhcPLOy9zXYUHTdP CdFVm3Hbti4PKN53KQ8lIJnWvOA8NqTab+WyEPMvb1p6fKsayRSuQplrwy90wD91Bf+2upxCQ +4teZp0bKVmMM+bVgwWDfqIIWdsE93Zdxp9HZ16Q8OoTTt9sfMe4IceCJGS7aPusu1XxFZATc oe0dtUGi36EI90i88GwIM5zsijLXC8zFniQlAkeKpoMAH5LM3IGjyeS15TK8cXMW/qH7qfh6T JcAGv+Jvp+kUxlfVWMIc/Mdb8WiIK92kBEltAh9lhN9iY/xlucRji7cvpIjM4Y4j1R6I7A9Fb m2Q//cRt6bZ0SXmBUWwruP72ARFjZa7TKhIUN4c9Wd78LVZlKlnDqY7MRiqWri9s+nfV/smUa 9kysNyXqHZT06U8fjwbqV+oFXH8RD2FFb8IQVjW/T6fMqD1ru3iSz8H2fsvAKU6yZ/9T9vB5Y KNvW9kbnWiMGtiIio9n/JaRoIIwsKVIeqAD4ZUf+nXfGaYYsaP5r664qdh9Iz2+hi/SwYar7k iSif1xhU2hiZzHXiUajguS+kMUC6CVuK8MvG5HyBU9/Jh9Yie6Uh3RKTIAfFGCXOOUwCtd+uM XuhXf4ZMKOLc3pDUlxy0JDhkCS3vKlMAdkdGDxzSL/LdAZvbs94rThuZrY9qUk392r7iCDsuu eJ2YMvc3L8yhs4aUGpv/u7fZnayX2jVCEoMBUcaqHBQZlmONWfwskg/bnuT8HO3eUhRzx07Hq AB7R/GN 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: Thu, 18 Aug 2016 21:28:58 +0200 The kfree() function was called in a few cases by the savage_bci_cmdbuf() function during error handling even if a passed variable contained a null pointer. Adjust jump targets according to the Linux coding style convention. Signed-off-by: Markus Elfring --- drivers/gpu/drm/savage/savage_state.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/savage/savage_state.c b/drivers/gpu/drm/savage/savage_state.c index 3dc0d8f..5b484aa 100644 --- a/drivers/gpu/drm/savage/savage_state.c +++ b/drivers/gpu/drm/savage/savage_state.c @@ -1004,7 +1004,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ kvb_addr = memdup_user(cmdbuf->vb_addr, cmdbuf->vb_size); if (IS_ERR(kvb_addr)) { ret = PTR_ERR(kvb_addr); - goto done; + goto free_cmd; } cmdbuf->vb_addr = kvb_addr; } @@ -1013,13 +1013,13 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ GFP_KERNEL); if (kbox_addr == NULL) { ret = -ENOMEM; - goto done; + goto free_vb; } if (copy_from_user(kbox_addr, cmdbuf->box_addr, cmdbuf->nbox * sizeof(struct drm_clip_rect))) { ret = -EFAULT; - goto done; + goto free_vb; } cmdbuf->box_addr = kbox_addr; } @@ -1052,7 +1052,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ "beyond end of command buffer\n"); DMA_FLUSH(); ret = -EINVAL; - goto done; + goto free_box; } /* fall through */ case SAVAGE_CMD_DMA_PRIM: @@ -1071,7 +1071,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ cmdbuf->vb_stride, cmdbuf->nbox, cmdbuf->box_addr); if (ret != 0) - goto done; + goto free_box; first_draw_cmd = NULL; } } @@ -1086,7 +1086,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ "beyond end of command buffer\n"); DMA_FLUSH(); ret = -EINVAL; - goto done; + goto free_box; } ret = savage_dispatch_state(dev_priv, &cmd_header, (const uint32_t *)cmdbuf->cmd_addr); @@ -1099,7 +1099,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ "beyond end of command buffer\n"); DMA_FLUSH(); ret = -EINVAL; - goto done; + goto free_box; } ret = savage_dispatch_clear(dev_priv, &cmd_header, cmdbuf->cmd_addr, @@ -1117,12 +1117,12 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ cmd_header.cmd.cmd); DMA_FLUSH(); ret = -EINVAL; - goto done; + goto free_box; } if (ret != 0) { DMA_FLUSH(); - goto done; + goto free_box; } } @@ -1133,7 +1133,7 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ cmdbuf->nbox, cmdbuf->box_addr); if (ret != 0) { DMA_FLUSH(); - goto done; + goto free_box; } } @@ -1147,11 +1147,11 @@ int savage_bci_cmdbuf(struct drm_device *dev, void *data, struct drm_file *file_ savage_freelist_put(dev, dmabuf); } -done: - /* If we didn't need to allocate them, these'll be NULL */ - kfree(kcmd_addr); - kfree(kvb_addr); +free_box: kfree(kbox_addr); - +free_vb: + kfree(kvb_addr); +free_cmd: + kfree(kcmd_addr); return ret; }