Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751152AbbLZHIq (ORCPT ); Sat, 26 Dec 2015 02:08:46 -0500 Received: from mout.web.de ([212.227.17.11]:61517 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750805AbbLZHIn (ORCPT ); Sat, 26 Dec 2015 02:08:43 -0500 Subject: [PATCH v2] i2c-core: One function call less in acpi_i2c_space_handler() after error detection References: <201512261449.pmBxYtq3%fengguang.wu@intel.com> Cc: kbuild-all@01.org, LKML , kernel-janitors@vger.kernel.org, Julia Lawall To: linux-i2c@vger.kernel.org, Wolfram Sang From: SF Markus Elfring X-Enigmail-Draft-Status: N1110 Message-ID: <567E3CF3.10606@users.sourceforge.net> Date: Sat, 26 Dec 2015 08:08:35 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <201512261449.pmBxYtq3%fengguang.wu@intel.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:Zt5xklfW5qkmWjmQ9MXiPXyTlQESa5o/nmAbxGGrQIqiSOeXstM uTQxs1B8RLM/A/PKP0nQnvZ3cpMGsk7//O6M9cZ3GvlP04ZlzWjTPbCJIZAmVJy9U+jVCAL ZGbtVE7FSZCswGsTBQStBpptLy3jHGoVrYhtOADLYEhW2UjjlXmnJYxX8CqappOwcjT43qM iwd5yU0GQhAjF9tjjDk8g== X-UI-Out-Filterresults: notjunk:1;V01:K0:2HUSWT3NNis=:fLYdey8i6fydKUZt0fAt0G rXiigTKXFfunUHuVbVeHTAnfb/6KHSkpiEkM6vInpQ83eLniQUn3kHs5kbJ4Fimn5u9cedout 8dYuL+GaeDIKLS1dIIT9lej7szbuPyLWhOYysBm/fev1eNXkCc3dOyc3CnjsaRHPkzTP4zznC y5DDf1DNLxVUJtW6Y7b+30NJYzog11ckfRzv10Y5Ynyev/FVkwn9BhnSVAE93QgB58vrduyla Xh4ACOF0+FANd0wHRTfPbvqv4LW9J07DVxCuC3GCwAOZ6nS+iekZZ/lT8LvYtgUa24oPmi0MJ xGwyMaqAwL2GUD4bEPbtYhpsuRuvoC6XmeuiG/QxGd9bjZuxE7JgOkQ9vuOwR5FL6GRx9RxK1 QGW0zL32+4R0g0XFfbZRm+Ai5ZmSnvM9V3J7DY/hnklQQo62sCFIxK3Ge/7RMYWjfdY+vFvxF 6SwYTel14ry7GpM2k+P2uGr4JCQr3T+n7Z3QH9FWT50UggeajWXitm9IBZ5pm4b9F2I4QVBsc DV5qrw/D1nVXEGwYUFSziVpSM6zWtnSpC+6rEbkD3UMnt5XFZm3y9HeqZapT4/L9zXhaO4hSq S5wmimUcEzVkovshjYVEFyyUTEkwRoB1OH/Td4NHyE+f9Q2KZ81Y0i7GPIi2OkPkOrRpPXlFL wkSow0+y4dT+Jh99Zg86iLpc2iJivGAQTjeglcyt2D3QANKKDH1rvYekKF/PpC4oGvA2ZXqSb +FCWtdRHWPzLQaywOgr8OpJKKOSpmiHNYW8Rm8ckq8naixfTnAIe3rtm+HdfvRFtusQQKUc5r zhvfjnp Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1887 Lines: 68 From: Markus Elfring Date: Sat, 26 Dec 2015 08:00:52 +0100 The kfree() function was called in one case by the acpi_i2c_space_handler() function during error handling even if the passed variable "client" contained a null pointer. Implementation details could be improved by the adjustment of jump targets according to the Linux coding style convention. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/i2c/i2c-core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 7349b00..9996531 100644 --- a/drivers/i2c/i2c-core.c +++ b/drivers/i2c/i2c-core.c @@ -313,18 +313,18 @@ acpi_i2c_space_handler(u32 function, acpi_physical_address command, client = kzalloc(sizeof(*client), GFP_KERNEL); if (!client) { ret = AE_NO_MEMORY; - goto err; + goto free_ares; } if (!value64 || ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS) { ret = AE_BAD_PARAMETER; - goto err; + goto free_client; } sb = &ares->data.i2c_serial_bus; if (sb->type != ACPI_RESOURCE_SERIAL_TYPE_I2C) { ret = AE_BAD_PARAMETER; - goto err; + goto free_client; } client->adapter = adapter; @@ -401,13 +401,13 @@ acpi_i2c_space_handler(u32 function, acpi_physical_address command, default: pr_info("protocol(0x%02x) is not supported.\n", accessor_type); ret = AE_BAD_PARAMETER; - goto err; + goto free_client; } gsb->status = status; - - err: +free_client: kfree(client); +free_ares: ACPI_FREE(ares); return ret; } -- 2.6.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/