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: 55215 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by patches.linaro.org (Postfix) with ESMTPS id AE5DD2309B for ; Mon, 19 Oct 2015 00:10:59 +0000 (UTC) Received: by wiclg3 with SMTP id lg3sf5205304wic.3 for ; Sun, 18 Oct 2015 17:10:59 -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=o4HXtv9O5ZM78WM2vrbXcAhPb5FjGwFd3Op/komyFYE=; b=DN1y3Y9kIOY4QA6akjXF892poOKlys/O8UGKx8rzf0Qbf3pL23MGm9fIN07a5nq3+b E9x0fXjDmv7+YVCgW387NyGlSZfKyY2TYhz+IP2ZamsZ2otft7qtLsjXED9AtDRCJXYO SkGHio57Khj9/pgdRGau6IYUTfqXFgbEnr68AiQMnrAvDCOVcJYNBupay8d8oSkH0l1+ Y0frMr7Z+sRu1VWz/ErAy+xXlN8wF4tYjTVPa6rkz+cJ8Dk1V2o2erGZbDv0VZLg/FLG LWNhAfv+73k9SHvfRhJsTaVuGn51ywDmQ+aSKm+XzxZjEaGTnZJLI79yCH9XitVpCO9/ eETg== X-Gm-Message-State: ALoCoQnA82Zz4kU6Xkgge8ASkAUJsZS5nplCXjfslrjybW6zhhsOKKiIpkdDXYoo4q8Q1BLtzV4x X-Received: by 10.112.151.9 with SMTP id um9mr5984396lbb.19.1445213458985; Sun, 18 Oct 2015 17:10:58 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.25.145.132 with SMTP id t126ls559974lfd.89.gmail; Sun, 18 Oct 2015 17:10:58 -0700 (PDT) X-Received: by 10.25.207.82 with SMTP id f79mr8725393lfg.73.1445213458791; Sun, 18 Oct 2015 17:10:58 -0700 (PDT) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id rg9si20885295lbb.79.2015.10.18.17.10.58 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 18 Oct 2015 17:10:58 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by lbbwb3 with SMTP id wb3so68789554lbb.1 for ; Sun, 18 Oct 2015 17:10:58 -0700 (PDT) X-Received: by 10.112.146.104 with SMTP id tb8mr13201673lbb.35.1445213458476; Sun, 18 Oct 2015 17:10:58 -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.59.35 with SMTP id w3csp1167011lbq; Sun, 18 Oct 2015 17:10:57 -0700 (PDT) X-Received: by 10.68.168.2 with SMTP id zs2mr31437108pbb.154.1445213456766; Sun, 18 Oct 2015 17:10:56 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ip1si48239075pbc.157.2015.10.18.17.10.56; Sun, 18 Oct 2015 17:10:56 -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 S1752473AbbJSAKQ (ORCPT + 28 others); Sun, 18 Oct 2015 20:10:16 -0400 Received: from mail-lb0-f177.google.com ([209.85.217.177]:36760 "EHLO mail-lb0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751680AbbJSAJ4 (ORCPT ); Sun, 18 Oct 2015 20:09:56 -0400 Received: by lbcao8 with SMTP id ao8so129828820lbc.3 for ; Sun, 18 Oct 2015 17:09:55 -0700 (PDT) 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 Cc: linux-mediatek@lists.infradead.org, yingjoe.chen@mediatek.com, tglx@linutronix.de, klimov.linux@gmail.com, joe@perches.com, Alexey Klimov 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> 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.217.177 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(). 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);