From patchwork Sun Oct 25 23:21:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Klimov X-Patchwork-Id: 55516 Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp896710lbq; Sun, 25 Oct 2015 16:22:18 -0700 (PDT) X-Received: by 10.68.192.104 with SMTP id hf8mr18941981pbc.66.1445815337913; Sun, 25 Oct 2015 16:22:17 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id sd5si48635854pbc.26.2015.10.25.16.22.17; Sun, 25 Oct 2015 16:22:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752557AbbJYXV6 (ORCPT + 28 others); Sun, 25 Oct 2015 19:21:58 -0400 Received: from mail-wi0-f177.google.com ([209.85.212.177]:36088 "EHLO mail-wi0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752497AbbJYXV4 (ORCPT ); Sun, 25 Oct 2015 19:21:56 -0400 Received: by wicfx6 with SMTP id fx6so91747731wic.1 for ; Sun, 25 Oct 2015 16:21:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=g0RRgLBWkrAxNgRpQx6xeKlbbA9b8Xi/GpSVVNH5T1Q=; b=HS8xLiRyW37A3RDe1fBHOdNG3DKZD4lg/lVqUPr+RZIbn0/hFFdJnKVxB3OfWAnYvN xGbAhSWaVhRY1Nr8oTcYcMOyNqR/07+RlnLigVXYnY3r8etV0db3zfBvV3PtoeiyYRjd a8GorZBOlANnsGX8s1JViXFUktQAIM2WkoWPySKOrksnryng8+6e8VhdHpP6mDtnWn24 onEdEKWmtUodd6TAPrQXMqxj/J0SeYsOAtYXuaw9uw3r6nAAiULh851oor4cqSamMLzi JBrnj67N33lq0b38OF6M/oSs37b5RsRQ7nJePgb/JBPkjabkbtrJcDRCgruSqMu8vUNE 1Mow== 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=g0RRgLBWkrAxNgRpQx6xeKlbbA9b8Xi/GpSVVNH5T1Q=; b=MNPzTmYn/4Y5vSE6pPCUEBLw+4+MGyqo+0JJksDG1HxcIUzv4/lVs8lh5eT+7LPzE0 hRdNIhOkjfVpBXYM1hczB53cCXoeQ8JKKVE146fyiGqGH8l0/YJbIALslpz9WX9y9NVn RWcYy63Vuy/muW+13hzfQHdUaJ6LL97CYVs1tk1onY6M9YK13d+QOnMNHzLHCnoi5b/B 8Jkj4a0vdZ/qk0g/BZkyfVCQS2l4doIYQBNvPyndzHR6/hP6ZjiMHbUC5K2SOhWYGgFA p/0LtqOZVEsf2V/CxJHhJhogFLiOnoM169HeNSznWS07AegH44rU0hekcTDI4sPz2wap hFGA== X-Gm-Message-State: ALoCoQm295VTVH4sgnAJT/tqXUKKnU/zuhmZ1EZNlAPA0wHYT1EP7XTLQogLVSaGIp5vqvLs50qt X-Received: by 10.194.63.7 with SMTP id c7mr17174041wjs.70.1445815315391; Sun, 25 Oct 2015 16:21:55 -0700 (PDT) Received: from mtux.lan (host-2-101-188-230.as13285.net. [2.101.188.230]) by smtp.gmail.com with ESMTPSA id jj8sm11712633wid.2.2015.10.25.16.21.54 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 25 Oct 2015 16:21:54 -0700 (PDT) From: Alexey Klimov To: daniel.lezcano@linaro.org, matthias.bgg@gmail.com, linux-kernel@vger.kernel.org, joe@perches.com Cc: linux-mediatek@lists.infradead.org, yingjoe.chen@mediatek.com, tglx@linutronix.de, klimov.linux@gmail.com, Alexey Klimov Subject: [PATCH v3 3/3] clocksource: mtk_timer: fix memleak in mtk_timer_init() Date: Sun, 25 Oct 2015 23:21:24 +0000 Message-Id: <1445815284-10425-3-git-send-email-alexey.klimov@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1445815284-10425-1-git-send-email-alexey.klimov@linaro.org> References: <1445815284-10425-1-git-send-email-alexey.klimov@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- Changes in v3: -- none Changes in v2: -- added acked-by from Matthias drivers/clocksource/mtk_timer.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.1.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/ diff --git a/drivers/clocksource/mtk_timer.c b/drivers/clocksource/mtk_timer.c index 4ddddf4..454c00e 100644 --- a/drivers/clocksource/mtk_timer.c +++ b/drivers/clocksource/mtk_timer.c @@ -199,7 +199,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); @@ -254,5 +254,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);