From patchwork Wed Dec 12 14:22:44 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julia Lawall X-Patchwork-Id: 1867011 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 6AAC8DF215 for ; Wed, 12 Dec 2012 14:26:01 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TinD2-0000T9-5t; Wed, 12 Dec 2012 14:22:52 +0000 Received: from mail1-relais-roc.national.inria.fr ([192.134.164.82]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TinCz-0000Sm-2E for linux-arm-kernel@lists.infradead.org; Wed, 12 Dec 2012 14:22:50 +0000 X-IronPort-AV: E=Sophos;i="4.84,266,1355094000"; d="scan'208";a="185806987" Received: from technetium.rsr.lip6.fr ([132.227.76.37]) by mail1-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 12 Dec 2012 15:22:44 +0100 Date: Wed, 12 Dec 2012 15:22:44 +0100 (CET) From: Julia Lawall X-X-Sender: jll@hadrien To: Jean-Christophe PLAGNIOL-VILLARD Subject: Re: [PATCH] drivers/pinctrl/pinctrl-at91.c: convert kfree to devm_kfree In-Reply-To: <20121212115624.GI4398@game.jcrosoft.org> Message-ID: References: <1355223525-19165-1-git-send-email-Julia.Lawall@lip6.fr> <20121212115624.GI4398@game.jcrosoft.org> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121212_092249_344059_F6F21DC8 X-CRM114-Status: GOOD ( 11.42 ) X-Spam-Score: -6.1 (------) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-6.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -5.0 RCVD_IN_DNSWL_HI RBL: Sender listed at http://www.dnswl.org/, high trust [192.134.164.82 listed in list.dnswl.org] 0.8 SPF_NEUTRAL SPF: sender does not match SPF record (neutral) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Linus Walleij , kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org From: Julia Lawall The function at91_dt_node_to_map is ultimately called by the function pinctrl_get, which is an exported function. Since it is possible that this function is not called from within a probe function, for safety, the kfree is converted to a devm_kfree, to both free the data and remove it from the device in a failure situation. Signed-off-by: Julia Lawall Acked-by: Jean-Christophe PLAGNIOL-VILLARD --- v2: Drop cleanup of the call to devm_kzalloc at the same time. drivers/pinctrl/pinctrl-at91.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c index c5e7571..bff54bf 100644 --- a/drivers/pinctrl/pinctrl-at91.c +++ b/drivers/pinctrl/pinctrl-at91.c @@ -265,7 +265,7 @@ static int at91_dt_node_to_map(struct pinctrl_dev *pctldev, /* create mux map */ parent = of_get_parent(np); if (!parent) { - kfree(new_map); + devm_kfree(pctldev->dev, new_map); return -EINVAL; } new_map[0].type = PIN_MAP_TYPE_MUX_GROUP;