Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752450AbbFZMe7 (ORCPT ); Fri, 26 Jun 2015 08:34:59 -0400 Received: from mail-wg0-f43.google.com ([74.125.82.43]:33727 "EHLO mail-wg0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752194AbbFZMef (ORCPT ); Fri, 26 Jun 2015 08:34:35 -0400 From: David Dueck To: boris.brezillon@free-electrons.com Cc: mturquette@linaro.org, nicolas.ferre@atmel.com, sboyd@codeaurora.org, linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/6] clk: at91: clk-system: fix error path Date: Fri, 26 Jun 2015 14:33:31 +0200 Message-Id: <1435322012-5667-5-git-send-email-davidcdueck@googlemail.com> X-Mailer: git-send-email 2.4.4 In-Reply-To: <1435322012-5667-1-git-send-email-davidcdueck@googlemail.com> References: <1435322012-5667-1-git-send-email-davidcdueck@googlemail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1117 Lines: 40 Do not leak memory if request_irq fails and free the irq if clk_register fails. Signed-off-by: David Dueck --- drivers/clk/at91/clk-system.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/clk/at91/clk-system.c b/drivers/clk/at91/clk-system.c index a76d03f..58008b3 100644 --- a/drivers/clk/at91/clk-system.c +++ b/drivers/clk/at91/clk-system.c @@ -130,13 +130,17 @@ at91_clk_register_system(struct at91_pmc *pmc, const char *name, irq_set_status_flags(sys->irq, IRQ_NOAUTOEN); ret = request_irq(sys->irq, clk_system_irq_handler, IRQF_TRIGGER_HIGH, name, sys); - if (ret) + if (ret) { + kfree(sys); return ERR_PTR(ret); + } } clk = clk_register(NULL, &sys->hw); - if (IS_ERR(clk)) + if (IS_ERR(clk)) { + free_irq(sys->irq, sys); kfree(sys); + } return clk; } -- 2.4.4 -- 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/