Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750948AbbLZGfU (ORCPT ); Sat, 26 Dec 2015 01:35:20 -0500 Received: from mout.web.de ([212.227.17.11]:50245 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750744AbbLZGfQ (ORCPT ); Sat, 26 Dec 2015 01:35:16 -0500 Subject: [PATCH] i2c-core: One function call less in acpi_i2c_space_handler() after error detection References: <566ABCD9.1060404@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall To: linux-i2c@vger.kernel.org, Wolfram Sang From: SF Markus Elfring Message-ID: <567E3511.6010606@users.sourceforge.net> Date: Sat, 26 Dec 2015 07:34:57 +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: <566ABCD9.1060404@users.sourceforge.net> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:pQFic7OlYNDp5MCu2Ns/sNj6bnWLYG243a+xZiV48HYdZw8mZOF 4kYcNmIm1DNTsI4VUf2hTDoLJOtgzHL6HVfkbI92T3RZf0gii1bNjcEb3GZgrkh7I93fBv1 RtgCmhHcpi+P/j2kzF12YBgab4R17mhL4Bi4EoAuNdGW+ydUbmycq+tGx+T8nmNOWvsSK9E l0ZNqw5tU/M3xzqAwrcWA== X-UI-Out-Filterresults: notjunk:1;V01:K0:hfXil91cLWQ=:rM+jlyuGfTfIcLfhzrPmMq EUpipgVXzjf6Icf/GokXwMmpGz+Kg6Ocs+hgm6lD5hA5pC2ZvdOQZyGwe742rJUFk1Qk9EeF2 HqDJcHwRWzIMIMpq9cVoWv9EuF1iJ7Cz3+oW1DuG0UMhqrQZKyIHxjSfT+HVI+a7hcSke0+IR UL6//4UiG0lgbkzA4do3m3NMYjxzZe3b+G5YR3Fnc6CBriZlLy+r8gYvNqvTMeM6zzRTotd8b BInOshkQtFU++3rdC0Opg37DLCJKv0WQT7h/UCrfLj8q9bR7FPvw3QbhzUcXiVD8H6MmikGGR Kdca+DgVjPcNkNdJmR8pLLNJ6xvRjXLHigxg/1y89Xvxi3wPuRWQ7zhnko1E86YOozWVR+A8P ZxpRCgXONY+cBHgWhd6uTc9haivjVW6PDY9rDgz3q42mgVtt+2sB9JD07jkX96/X56JA3HOb2 ePo4lsDVXQbJvVhZSkXOgwXbdZbo3RQPI4jobeA1t6DdFh8la8ZqpoX5GT55N+yptcTdjHDb8 RDbNBGzT4NSzTpr4qPBGnrGf0VVOcIs5b/npcNE92czuG1SKMsvfr0bYA7iYfkFSqy88Gmyk1 HXBl3T8DpzUWJTmHf2x2OCsbv4L4hAYr3AG+k79E4XAyHQYbKm+HY2sXEpRePs6Hoo02egw/f 5hnj2H5UVhWxs/OJ3RF9E7EoC4KhZ+It10MTHk2FuZuWP9vXwtcPlr649h6hBH7ZLTT4jYSiw F5yciMkhSu//6erMKr2qiej9NIySD7mCI1k9U5FXN4CIc3d1cEXIHyww3rONZLWrWbZXK76P+ Abjwj+V Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1697 Lines: 62 From: Markus Elfring Date: Sat, 26 Dec 2015 07:30:35 +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. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/i2c/i2c-core.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/i2c/i2c-core.c b/drivers/i2c/i2c-core.c index 7349b00..a24e06c 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; @@ -405,9 +405,9 @@ acpi_i2c_space_handler(u32 function, acpi_physical_address command, } 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/