From nobody Sat Oct 4 15:57:32 2025 Received: from mail-m32117.qiye.163.com (mail-m32117.qiye.163.com [220.197.32.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 544D02F99B5; Thu, 14 Aug 2025 12:48:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.32.117 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755175745; cv=none; b=IfRcOtbJVABnXp973r2hDjSv9CCs7nrzP4nsF0hEkirfKC0V2GLjWHPllX9KqPq/lkNNqwa11NcsU24rWMRDnzTHdfhibSc0p1PXKBLebHsh9oql1EEa7Ftz5Saq6olGDrzZGknnt7P37sIwfhBDy28tFb1m2RDs8R3kxQmvzzs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755175745; c=relaxed/simple; bh=HZXTqrMNKlFg3UlZn0yyHm1+KqoxMpzwhmq/LswL8XU=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eKx08Dcrc9dnBCIDIfcitiRzQET6lSzruxvWzQQ6UFXWahvLdvesqTDkLf+ecpXlcVm+pbBCukodeQoCxGptfaJlnCsByi3s8i93CZUCbaSMsGfbmM4vzTZ/WrFdRk0chlor0LMfQX6ZknEK3xWaceuQMn1VsAhjplfUDq1oDdo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=easystack.cn; spf=pass smtp.mailfrom=easystack.cn; arc=none smtp.client-ip=220.197.32.117 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=easystack.cn Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=easystack.cn Received: from localhost.localdomain (unknown [218.94.118.90]) by smtp.qiye.163.com (Hmail) with ESMTP id ea2a95ec; Thu, 14 Aug 2025 20:33:33 +0800 (GMT+08:00) From: Zhen Ni To: daniel.lezcano@linaro.org, tglx@linutronix.de Cc: linux-kernel@vger.kernel.org, Zhen Ni , stable@vger.kernel.org Subject: [PATCH v3] clocksource: clps711x: Fix resource leaks in error paths Date: Thu, 14 Aug 2025 20:33:24 +0800 Message-Id: <20250814123324.1516495-1-zhen.ni@easystack.cn> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20250804123619.78282-1-zhen.ni@easystack.cn> References: <20250804123619.78282-1-zhen.ni@easystack.cn> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-HM-Tid: 0a98a8923e020229kunm667a5e1267a246 X-HM-MType: 1 X-HM-Spam-Status: e1kfGhgUHx5ZQUpXWQgPGg8OCBgUHx5ZQUlOS1dZFg8aDwILHllBWSg2Ly tZV1koWUFJQjdXWS1ZQUlXWQ8JGhUIEh9ZQVlCHRhPVkhNTR9NQk1KGRlMSFYVFAkWGhdVGRETFh oSFyQUDg9ZV1kYEgtZQVlJSkNVQk9VSkpDVUJLWVdZFhoPEhUdFFlBWU9LSFVKS0lPT09IVUpLS1 VKQktLWQY+ Content-Type: text/plain; charset="utf-8" The current implementation of clps711x_timer_init() has multiple error paths that directly return without releasing the base I/O memory mapped via of_iomap(). Fix of_iomap leaks in error paths. Fixes: 04410efbb6bc ("clocksource/drivers/clps711x: Convert init function t= o return error") Fixes: 2a6a8e2d9004 ("clocksource/drivers/clps711x: Remove board support") Cc: stable@vger.kernel.org Signed-off-by: Zhen Ni --- changes in v3: - Change "err" to "error" in the commit message. changes in v2: - Add tags of 'Fixes' and 'Cc' - Reduce detailed enumeration of err paths - Omit a pointer check before iounmap() - Change goto target from out to unmap_io --- drivers/clocksource/clps711x-timer.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/drivers/clocksource/clps711x-timer.c b/drivers/clocksource/clp= s711x-timer.c index e95fdc49c226..bbceb0289d45 100644 --- a/drivers/clocksource/clps711x-timer.c +++ b/drivers/clocksource/clps711x-timer.c @@ -78,24 +78,33 @@ static int __init clps711x_timer_init(struct device_nod= e *np) unsigned int irq =3D irq_of_parse_and_map(np, 0); struct clk *clock =3D of_clk_get(np, 0); void __iomem *base =3D of_iomap(np, 0); + int ret =3D 0; =20 if (!base) return -ENOMEM; - if (!irq) - return -EINVAL; - if (IS_ERR(clock)) - return PTR_ERR(clock); + if (!irq) { + ret =3D -EINVAL; + goto unmap_io; + } + if (IS_ERR(clock)) { + ret =3D PTR_ERR(clock); + goto unmap_io; + } =20 switch (of_alias_get_id(np, "timer")) { case CLPS711X_CLKSRC_CLOCKSOURCE: clps711x_clksrc_init(clock, base); break; case CLPS711X_CLKSRC_CLOCKEVENT: - return _clps711x_clkevt_init(clock, base, irq); + ret =3D _clps711x_clkevt_init(clock, base, irq); + break; default: - return -EINVAL; + ret =3D -EINVAL; + break; } =20 - return 0; +unmap_io: + iounmap(base); + return ret; } TIMER_OF_DECLARE(clps711x, "cirrus,ep7209-timer", clps711x_timer_init); --=20 2.20.1