From patchwork Mon Oct 19 00:09:25 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Klimov X-Patchwork-Id: 7432421 Return-Path: X-Original-To: patchwork-linux-mediatek@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1FB69BEEA4 for ; Mon, 19 Oct 2015 00:10:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 2B49F2066E for ; Mon, 19 Oct 2015 00:10:25 +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 5EB7620664 for ; Mon, 19 Oct 2015 00:10:23 +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 1Zny1t-00024M-Sr; Mon, 19 Oct 2015 00:10:21 +0000 Received: from mail-lb0-f179.google.com ([209.85.217.179]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Zny1r-0000qs-4G for linux-mediatek@lists.infradead.org; Mon, 19 Oct 2015 00:10:20 +0000 Received: by lbbwb3 with SMTP id wb3so68781437lbb.1 for ; Sun, 18 Oct 2015 17:09:55 -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=SOdLkBRd2cz0uYK/R+352zdNf1QB8cio9Xx5UajupMw=; b=Q4JL4TFbaW2O3vrEu2osRWYB9836KBmratqAMXxYMa/tfftcQk5M0StO6H8JMtx9RX ggj4/lGsOFCpqJIaR8gfhCvSZrY0lKZ3BBMco9zN59q8dikY3J1k6sjdDcZ3f1mMvvpT Z/3DE0cxe4n10+Jpm5huFsP18xzJJL7A1pwxRCJEmtz+Gzl85DPhADHJtCs6bRwcdqxm wzI4OCeUNxL0Xx9v07zuY6l4EGY5xkyK1crp3neaMTq+FxtTKtkziuw0dLEDdJsxQW30 4nsDCBwqmQpEinfWLJOR7S5Zqc4tv+1PbAz7IsIdpOqe36H2E1XrT44CCZiSlW4pNsHt /xrg== X-Gm-Message-State: ALoCoQlih7iLnhzhRVt0wSKsOoHW7ltIHEyErMLqFrYwAGpG+N93OfNjj1CGPl1X620h3HM4yFhY X-Received: by 10.112.134.73 with SMTP id pi9mr12929406lbb.83.1445213394936; Sun, 18 Oct 2015 17:09:54 -0700 (PDT) Received: from localhost.localdomain ([188.123.252.216]) by smtp.gmail.com with ESMTPSA id t188sm4878359lfe.33.2015.10.18.17.09.53 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 18 Oct 2015 17:09:54 -0700 (PDT) From: Alexey Klimov To: daniel.lezcano@linaro.org, matthias.bgg@gmail.com, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/3] clocksource: mtk_timer: fix memleak in mtk_timer_init() Date: Mon, 19 Oct 2015 03:09:25 +0300 Message-Id: <1445213365-24530-3-git-send-email-alexey.klimov@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1445213365-24530-1-git-send-email-alexey.klimov@linaro.org> References: <1445213365-24530-1-git-send-email-alexey.klimov@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20151018_171019_371236_903ED875 X-CRM114-Status: GOOD ( 10.46 ) 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: klimov.linux@gmail.com, linux-mediatek@lists.infradead.org, joe@perches.com, yingjoe.chen@mediatek.com, tglx@linutronix.de, Alexey Klimov 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(). Acked-by: Matthias Brugger Signed-off-by: Alexey Klimov --- 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 ac92ca2..a811e7c 100644 --- a/drivers/clocksource/mtk_timer.c +++ b/drivers/clocksource/mtk_timer.c @@ -200,7 +200,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); @@ -255,5 +255,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);