From mboxrd@z Thu Jan 1 00:00:00 1970 From: SF Markus Elfring Subject: [PATCH v2] i2c-core: One function call less in acpi_i2c_space_handler() after error detection Date: Sat, 26 Dec 2015 08:08:35 +0100 Message-ID: <567E3CF3.10606@users.sourceforge.net> References: <201512261449.pmBxYtq3%fengguang.wu@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <201512261449.pmBxYtq3%fengguang.wu@intel.com> Sender: kernel-janitors-owner@vger.kernel.org To: linux-i2c@vger.kernel.org, Wolfram Sang Cc: kbuild-all@01.org, LKML , kernel-janitors@vger.kernel.org, Julia Lawall List-Id: linux-i2c@vger.kernel.org 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