From patchwork Sat Jul 16 14:50:24 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: 9233257 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 19EE56075D for ; Sat, 16 Jul 2016 14:56:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0BA1D2236A for ; Sat, 16 Jul 2016 14:56:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE98220951; Sat, 16 Jul 2016 14:56:04 +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 56A2A20951 for ; Sat, 16 Jul 2016 14:56:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E4B9E6E2C2; Sat, 16 Jul 2016 14:56:01 +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.17.12]) by gabe.freedesktop.org (Postfix) with ESMTPS id E81D26E2C2 for ; Sat, 16 Jul 2016 14:55:58 +0000 (UTC) Received: from [192.168.1.2] ([77.182.189.163]) by smtp.web.de (mrweb101) with ESMTPSA (Nemesis) id 0MbhFJ-1bhLFi2txl-00J53U; Sat, 16 Jul 2016 16:50:39 +0200 Subject: [PATCH 3/8] drm/amdgpu: One function call less in amdgpu_cgs_acpi_eval_object() after error detection To: dri-devel@lists.freedesktop.org, David Airlie , =?UTF-8?Q?Christian_K=c3=b6nig?= , Alex Deucher 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> <558FB427.80103@users.sourceforge.net> From: SF Markus Elfring Message-ID: Date: Sat, 16 Jul 2016 16:50:24 +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: X-Provags-ID: V03:K0:CDNbfdf0MR/+QeKq2NUuHNTKijqc76iXgQd1kZPQZtKhJdT23Zy isNAKLNkTw9KAk/g9hGx+Yd7P8gNRiE8v+sa2YEo8n+DTNwG1CUra5D4PxmdCzjKKj6NgZl s6FIQ2IxHwRvEEbbmmW+752vstpRVHuhYrZ9zVZ4UxStUrTF1UE3NehG6pADryFyR+hn7/C 8E/y/iuFvHY4gDuwpYEtQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:CAGS8JDpRTk=:lgnO7T+pisXFbYjhicqtt8 tQEXs5kEL4UCI4EzvnBRE4nUPSIW1iPLuVviVVxesFto/LXEYiKo/t1MDvTgrkw98KYsddLre DnTVgnJp3xWj26ahqtJvgS8/dTju5sBK4TpKhF8jgH06X2P7axqG5rzf0sdgLqX6oz5qYr3P8 tSgy+6hlaGTYwj0Yh/FzvcIfy63Dh8i+9PRWnXIXJsBmBFGNaHOzWYbIKjBEZxoml9vUoqd6T u5JXkFdvNfJhUNl8rlSpgD1+j0bMMDdsLuQaYPh2xOD0O1RjSR3Ghgi3x9plsuswTVYmA0rY+ D50YbfIpGjmOubOA3S77Az+gSO5VaHCmEdsd0bShVEXTg0vG75P5DKkEHnAPPsxon32ZN7pW6 GHaYUkLD3GxOUrisV3HdH1dzWNEhZ/oCX9EZ2x5PYHTTbPHL8WeSdCAMnxLZLxIzeeA+KiqE/ 9keXI+8k8ltXoMxUETXWuwEAtC4JJsmqxbnJG6TCXlNFuZOIRzpvrzLATAPG20dYDE6n501K6 sIwqq4Ido+ZOLh6Zg21egYe4kJO9m7kGYhcyhFC+K8MykNvVhq6ouY1CeCowwYvt5Kjsm0wlj wOyNJ+IPdfkJZQxTuVmRGWvQlFcf8Y6/WysOLT/lh61AK6TEil3QpbLzuCnBiEzChAmztF1sP OBiXrw9bqJX18rq9hV2oc3jCBf99ifaflx9tYIZawhRKMEUBUa7s6MIhToYDk/7dom4kbMp/s 3Q93eJiEIgVypUaBerSWw2JUDCUUdQgIifcnypg4LeD4ySZgyL1mV1i6cN8/2tXbUeweVfAt6 Vz018pD 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: Sat, 16 Jul 2016 13:43:44 +0200 The kfree() function was called in one case by the amdgpu_cgs_acpi_eval_object() function during error handling even if the passed variable "obj" contained a null pointer. * Adjust jump targets according to the Linux coding style convention. * Delete unnecessary initialisations for the variables "obj" and "params" then. Signed-off-by: Markus Elfring --- drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c index 6f11bc1..705bfa2 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cgs.c @@ -903,8 +903,7 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device, acpi_handle handle; struct acpi_object_list input; struct acpi_buffer output = { ACPI_ALLOCATE_BUFFER, NULL }; - union acpi_object *params = NULL; - union acpi_object *obj = NULL; + union acpi_object *params, *obj; uint8_t name[5] = {'\0'}; struct cgs_acpi_method_argument *argument = NULL; uint32_t i, count; @@ -996,7 +995,7 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device, if (ACPI_FAILURE(status)) { result = -EIO; - goto error; + goto free_input; } /* return the output info */ @@ -1006,7 +1005,7 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device, if ((obj->type != ACPI_TYPE_PACKAGE) || (obj->package.count != count)) { result = -EIO; - goto error; + goto free_obj; } params = obj->package.elements; } else @@ -1014,13 +1013,13 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device, if (params == NULL) { result = -EIO; - goto error; + goto free_obj; } for (i = 0; i < count; i++) { if (argument->type != params->type) { result = -EIO; - goto error; + goto free_obj; } switch (params->type) { case ACPI_TYPE_INTEGER: @@ -1030,7 +1029,7 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device, if ((params->string.length != argument->data_length) || (params->string.pointer == NULL)) { result = -EIO; - goto error; + goto free_obj; } strncpy(argument->pointer, params->string.pointer, @@ -1039,7 +1038,7 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device, case ACPI_TYPE_BUFFER: if (params->buffer.pointer == NULL) { result = -EIO; - goto error; + goto free_obj; } memcpy(argument->pointer, params->buffer.pointer, @@ -1052,8 +1051,9 @@ static int amdgpu_cgs_acpi_eval_object(struct cgs_device *cgs_device, params++; } -error: +free_obj: kfree(obj); +free_input: kfree((void *)input.pointer); return result; }