From patchwork Fri Sep 4 03:21:40 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Klimov X-Patchwork-Id: 7119891 Return-Path: X-Original-To: patchwork-linux-mediatek@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3FB449F380 for ; Fri, 4 Sep 2015 03:22:42 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6F9B92081B for ; Fri, 4 Sep 2015 03:22:41 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7730A2089A for ; Fri, 4 Sep 2015 03:22:40 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZXhaK-0001ff-71; Fri, 04 Sep 2015 03:22:40 +0000 Received: from mail-la0-f53.google.com ([209.85.215.53]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZXhaJ-0001d1-01 for linux-mediatek@lists.infradead.org; Fri, 04 Sep 2015 03:22:39 +0000 Received: by lamp12 with SMTP id p12so5091507lam.0 for ; Thu, 03 Sep 2015 20:22:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=esZpvOa8LBLMh4ZGsu24U2WRrRi3cj/L/bLxUtluZ38=; b=WdbY4Qt41Onhv+rl+k4+X7H4ZfdoUKo/oitnIkB+JUYwy/qTEi8g472jy2gz6aymQG tvuH+0A6VFxLc5MdNqSCCBoMZiLMz+4uNSCan2SWrsK1bnEvETw/3SzpOk853NBuehMr qfMy9eqsaQKyTt4FgFNlsj/5+4Z2qlDo7inH9W5joCnut1rdz7xUZmacTmt/PAzwZ/VI PaaFh53ZGnMouLenPIGCXAnUKUY3Z0TJ7zHEYlURc6LpXYTB8bW4xCA5TVBo+kca2t5c ifQ4Z68S9AWAyyqg74ai1Mj/jv2KkW9oEOzpsX99TOxTIeq8ztPyu+fbqu/Jx0BdgGSH ILVw== X-Gm-Message-State: ALoCoQkienRnLK/7ZNwCZCtL+P/ue5zLAsd3dNBOTEwHM8VII0va5tedodCkTqvpMGReZMNgz51z X-Received: by 10.152.5.201 with SMTP id u9mr1347856lau.26.1441336935783; Thu, 03 Sep 2015 20:22:15 -0700 (PDT) Received: from localhost.localdomain ([46.39.50.164]) by smtp.gmail.com with ESMTPSA id t2sm216126lag.36.2015.09.03.20.22.14 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 03 Sep 2015 20:22:15 -0700 (PDT) From: Alexey Klimov To: daniel.lezcano@linaro.org, linux-mediatek@lists.infradead.org, matthias.bgg@gmail.com Subject: [RFC PATCH 3/3] clocksource: mtk_timer: fix memleak in mtk_timer_init() Date: Fri, 4 Sep 2015 06:21:40 +0300 Message-Id: <1441336900-15095-3-git-send-email-alexey.klimov@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1441336900-15095-1-git-send-email-alexey.klimov@linaro.org> References: <1441336900-15095-1-git-send-email-alexey.klimov@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150903_202239_222853_838E3546 X-CRM114-Status: UNSURE ( 9.52 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -2.6 (--) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: yingjoe.chen@mediatek.com, tglx@linutronix.de, Alexey Klimov , linux-kernel@vger.kernel.org, klimov.linux@gmail.com MIME-Version: 1.0 Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add error path to clear evt struct allocated by kzalloc() in the beginning of function mtk_timer_init(). Signed-off-by: Alexey Klimov Acked-by: Matthias Brugger --- drivers/clocksource/mtk_timer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/clocksource/mtk_timer.c b/drivers/clocksource/mtk_timer.c index fbaacbf..9c5a2cc 100644 --- a/drivers/clocksource/mtk_timer.c +++ b/drivers/clocksource/mtk_timer.c @@ -201,7 +201,7 @@ static void __init mtk_timer_init(struct device_node *node) evt->gpt_base = of_io_request_and_map(node, 0, "mtk-timer"); if (IS_ERR(evt->gpt_base)) { pr_err("Can't get resource\n"); - return; + goto err_kzalloc; } evt->dev.irq = irq_of_parse_and_map(node, 0); @@ -256,5 +256,7 @@ err_mem: iounmap(evt->gpt_base); of_address_to_resource(node, 0, &res); release_mem_region(res.start, resource_size(&res)); +err_kzalloc: + kfree(evt); } CLOCKSOURCE_OF_DECLARE(mtk_mt6577, "mediatek,mt6577-timer", mtk_timer_init);