From nobody Sun Feb 8 03:58:31 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA18FEB64D7 for ; Mon, 26 Jun 2023 09:13:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229501AbjFZJNn (ORCPT ); Mon, 26 Jun 2023 05:13:43 -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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the timers/core branch of tip: Commit-ID: 8b5bf64c89c7100c921bd807ba39b2eb003061ab Gitweb: https://git.kernel.org/tip/8b5bf64c89c7100c921bd807ba39b2eb0= 03061ab Author: Feng Mingxi AuthorDate: Tue, 25 Apr 2023 06:56:11=20 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 functio= n 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_dev= ice *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 =3D of_iomap(timer, 0); - if (!timer_baseaddr) { + timer_baseaddr =3D 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); } =20 irq =3D irq_of_parse_and_map(timer, 1); @@ -513,20 +513,27 @@ static int __init ttc_timer_probe(struct platform_dev= ice *pdev) clk_ce =3D 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 =3D PTR_ERR(clk_ce); + goto put_clk_cs; } =20 ret =3D ttc_setup_clocksource(clk_cs, timer_baseaddr, timer_width); if (ret) - return ret; + goto put_clk_ce; =20 ret =3D ttc_setup_clockevent(clk_ce, timer_baseaddr + 4, irq); if (ret) - return ret; + goto put_clk_ce; =20 pr_info("%pOFn #0 at %p, irq=3D%d\n", timer, timer_baseaddr, irq); =20 return 0; + +put_clk_ce: + clk_put(clk_ce); +put_clk_cs: + clk_put(clk_cs); + return ret; } =20 static const struct of_device_id ttc_timer_of_match[] =3D {