From patchwork Mon Jun 26 09:11:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 112808 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp7348224vqr; Mon, 26 Jun 2023 02:20:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ65P3/OK0vlVF+Iu6Ntnh/wUHDCVB8So2+waCeU21PJuLNydleUV1jLnKGFVcBgM7KDLLtd X-Received: by 2002:a17:907:9415:b0:979:dad9:4e9 with SMTP id dk21-20020a170907941500b00979dad904e9mr28094937ejc.50.1687771213165; Mon, 26 Jun 2023 02:20:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687771213; cv=none; d=google.com; s=arc-20160816; b=u7YEJ2jeQKTpoiQfpsx5jCJPdtWrQ9XgmytyKypDfjqvCG7foTgcMgTFdb8g4ySgY3 tot4WwkqCLHsNZvjbgoONRnVjbBuYO81tnc5oRzURHO4NscjUYd7tKMoMON1Bx0JJj8a XtlyLjXbwvkSlmpfxc3DatMwk8oyHzxlq7Ffuvp5Iv6mO9hxOxABwgTHFmN3L7UP9eBh CVpsZMOymLpi8Pg2+8VXjWG4eDaGTJKLEaGunoEJJ5whFn5HbIhNs4ALLLXGt7RQmIw6 GSGfC1VwBWYKGpjtdfxILfFFl+SYErHxMlSr5b2xtpkpxa06zdARAxuoR/M6PaLRlXP1 6NTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=FYRP6z4QKxCBiYjPMLKBD3XHq0H+6p1m4dbVc9Rnm+0=; fh=FXvyLhg34YM44ZHSjJ7trBfyGXrvKqP/4KEX/UD6X/8=; b=CbJvilNGyLBHPJ8yNCQUf3l7XFiAebvcFuCzEF833qBXQc/ZtpQx5JFnoJ+hTjn9D0 6e2ywe5dd3GPDjYg2bUB6dV3MyT14WHPJjPSbm9rNMNz/lnYRbxsVLTnX3b8xsRSqzai MZTNIHg/2XqHfQam4BfIPn5vG+P6khDSD0B8eukN5RtJS4j3Ve3BY1f58mjOy4s7FDBC FI9R0GmSdomZdQjI8cxdP5pyY3eyk0p028A1DT6SuL7gYb22IIwA75r3dra8V7xw8iHW R1dvAS4m+pZwe80m95Ngi9eUjYzhGgSfGMPvN/ZMoWrEm3k7M8J0/6kZVZOTzXCefeWh XLqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=QveTFLnL; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bx13-20020a170906a1cd00b00982733d446csi2640011ejb.410.2023.06.26.02.19.47; Mon, 26 Jun 2023 02:20:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=QveTFLnL; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230195AbjFZJNl (ORCPT + 99 others); Mon, 26 Jun 2023 05:13:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229597AbjFZJNJ (ORCPT ); Mon, 26 Jun 2023 05:13:09 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BB7893; Mon, 26 Jun 2023 02:11:37 -0700 (PDT) Date: Mon, 26 Jun 2023 09:11:35 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1687770696; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FYRP6z4QKxCBiYjPMLKBD3XHq0H+6p1m4dbVc9Rnm+0=; b=QveTFLnLbtxagDDdX3NXdbcXdf0SvYfnu8DZ9Il5ZEAOmubZRckgu5Zn2r3J/IySdNgutA 4kpiSUZ977jSRySnDIp9l/e3x9eHdrsoynNRGoq6XCJaIo3XkjlYNAvrAm/jBtTz6xabyY CbMWRQ1EEN4XTGSYGV6iSDvOTf7WU+t8/szPzQogZcmbTQP6o/nm1m4AnT8Td5N57UjwG9 qkagWazdZqxsnRNgIyPhR+xGoCtguZtgFqakEnedX8dajR0lc9QrvB8fZs6XJI8NiGjFUy mQk0G5KWvHc4PRPCKW5grqYmvLu6WCJIqaHTjA+Nu/x7PmJkL9TlbpSl92NVfg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1687770696; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FYRP6z4QKxCBiYjPMLKBD3XHq0H+6p1m4dbVc9Rnm+0=; b=aPVFAxYtxttOkpGtwEWSj+2GNObVyYGxJE45IKBSWHfXX3iPir3rk+0+Lf8hxBBD9I/t7V 6FaAtLTWaVRoQcBA== From: "tip-bot2 for Feng Mingxi" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: timers/core] clocksource/drivers/cadence-ttc: Fix memory leak in ttc_timer_probe Cc: Feng Mingxi , Dongliang Mu , Michal Simek , Daniel Lezcano , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20230425065611.702917-1-m202271825@hust.edu.cn> References: <20230425065611.702917-1-m202271825@hust.edu.cn> MIME-Version: 1.0 Message-ID: <168777069558.404.17748675631508303301.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769756387627678786?= X-GMAIL-MSGID: =?utf-8?q?1769756387627678786?= The following commit has been merged into the timers/core branch of tip: Commit-ID: 8b5bf64c89c7100c921bd807ba39b2eb003061ab Gitweb: https://git.kernel.org/tip/8b5bf64c89c7100c921bd807ba39b2eb003061ab Author: Feng Mingxi AuthorDate: Tue, 25 Apr 2023 06:56:11 Committer: Daniel Lezcano CommitterDate: Fri, 23 Jun 2023 09:33:44 +02:00 clocksource/drivers/cadence-ttc: Fix memory leak in ttc_timer_probe Smatch reports: drivers/clocksource/timer-cadence-ttc.c:529 ttc_timer_probe() warn: 'timer_baseaddr' from of_iomap() not released on lines: 498,508,516. timer_baseaddr may have the problem of not being released after use, I replaced it with the devm_of_iomap() function and added the clk_put() function to cleanup the "clk_ce" and "clk_cs". Fixes: e932900a3279 ("arm: zynq: Use standard timer binding") Fixes: 70504f311d4b ("clocksource/drivers/cadence_ttc: Convert init function to return error") Signed-off-by: Feng Mingxi Reviewed-by: Dongliang Mu Acked-by: Michal Simek Signed-off-by: Daniel Lezcano Link: https://lore.kernel.org/r/20230425065611.702917-1-m202271825@hust.edu.cn --- drivers/clocksource/timer-cadence-ttc.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/clocksource/timer-cadence-ttc.c b/drivers/clocksource/timer-cadence-ttc.c index 4efd0cf..0d52e28 100644 --- a/drivers/clocksource/timer-cadence-ttc.c +++ b/drivers/clocksource/timer-cadence-ttc.c @@ -486,10 +486,10 @@ static int __init ttc_timer_probe(struct platform_device *pdev) * and use it. Note that the event timer uses the interrupt and it's the * 2nd TTC hence the irq_of_parse_and_map(,1) */ - timer_baseaddr = of_iomap(timer, 0); - if (!timer_baseaddr) { + timer_baseaddr = devm_of_iomap(&pdev->dev, timer, 0, NULL); + if (IS_ERR(timer_baseaddr)) { pr_err("ERROR: invalid timer base address\n"); - return -ENXIO; + return PTR_ERR(timer_baseaddr); } irq = irq_of_parse_and_map(timer, 1); @@ -513,20 +513,27 @@ static int __init ttc_timer_probe(struct platform_device *pdev) clk_ce = of_clk_get(timer, clksel); if (IS_ERR(clk_ce)) { pr_err("ERROR: timer input clock not found\n"); - return PTR_ERR(clk_ce); + ret = PTR_ERR(clk_ce); + goto put_clk_cs; } ret = ttc_setup_clocksource(clk_cs, timer_baseaddr, timer_width); if (ret) - return ret; + goto put_clk_ce; ret = ttc_setup_clockevent(clk_ce, timer_baseaddr + 4, irq); if (ret) - return ret; + goto put_clk_ce; pr_info("%pOFn #0 at %p, irq=%d\n", timer, timer_baseaddr, irq); return 0; + +put_clk_ce: + clk_put(clk_ce); +put_clk_cs: + clk_put(clk_cs); + return ret; } static const struct of_device_id ttc_timer_of_match[] = {