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: 53065 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by patches.linaro.org (Postfix) with ESMTPS id 4B18822E3F for ; Fri, 4 Sep 2015 03:22:28 +0000 (UTC) Received: by lanb10 with SMTP id b10sf2703458lan.3 for ; Thu, 03 Sep 2015 20:22:27 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=z6+fITM8VT4nyG4eQp5QFM5vaJOJqnanzgRgGbcXj6g=; b=cyu/rFP7fYsioUvzlBa0pi549WDAISRG8yH5Z/6zwrEf6al6wh6cxBqB/y5AIwRbmR sZZm6N5y8JgTklylOYbUHHKS/EuVZbyS78Wgw2X3a1kCX1XzCPhRYcxvvRh0h4CaXTbb LcUX46djY/K/N0dj9zixQ7Yiup/JeVpOiqIKe2GoQ0ZWlCq4fzk2kPIMAo/BYjJvmjZW DLuqNif2hfU5CIT9XlUFT/NQEEGXU+db8MmDvy4t4GZ/X8wO2jTSHrAyYGRnOL1JEWwQ EqmGKE9j9JwAjvEi36neeqOTG5W/AP/bJ4tbEkR8Vw1OwrIkDTWXrKcDpDkTdOSMenBU acCg== X-Gm-Message-State: ALoCoQnBfI9dtC2kKR3lHOV1VliUybJB0sRFq7IxLrLdu9696QMfb30KW6/3stRnIQCs/1SbIQ50 X-Received: by 10.180.87.40 with SMTP id u8mr388136wiz.7.1441336947198; Thu, 03 Sep 2015 20:22:27 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.163.69 with SMTP id yg5ls278079lab.5.gmail; Thu, 03 Sep 2015 20:22:26 -0700 (PDT) X-Received: by 10.152.5.69 with SMTP id q5mr1289908laq.92.1441336946967; Thu, 03 Sep 2015 20:22:26 -0700 (PDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id wu4si945917lbb.69.2015.09.03.20.22.26 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Sep 2015 20:22:26 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by laeb10 with SMTP id b10so5273738lae.1 for ; Thu, 03 Sep 2015 20:22:26 -0700 (PDT) X-Received: by 10.112.198.202 with SMTP id je10mr1322756lbc.86.1441336946830; Thu, 03 Sep 2015 20:22:26 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.164.42 with SMTP id yn10csp1660680lbb; Thu, 3 Sep 2015 20:22:26 -0700 (PDT) X-Received: by 10.66.100.168 with SMTP id ez8mr3129957pab.142.1441336945870; Thu, 03 Sep 2015 20:22:25 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id jd5si1723396pbd.170.2015.09.03.20.22.24; Thu, 03 Sep 2015 20:22:25 -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; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756828AbbIDDWU (ORCPT + 28 others); Thu, 3 Sep 2015 23:22:20 -0400 Received: from mail-la0-f50.google.com ([209.85.215.50]:34111 "EHLO mail-la0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756640AbbIDDWR (ORCPT ); Thu, 3 Sep 2015 23:22:17 -0400 Received: by laeb10 with SMTP id b10so5272022lae.1 for ; Thu, 03 Sep 2015 20:22:15 -0700 (PDT) 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 Cc: yingjoe.chen@mediatek.com, tglx@linutronix.de, linux-kernel@vger.kernel.org, klimov.linux@gmail.com, Alexey Klimov 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> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: alexey.klimov@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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);