From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796385920; b=vCUTSUoX2pYxzrUP5nI/n+T+Gk1sW4b+7rUHIXs13P2Bsfv3sdIMf/IgWeb8U0+WVqaJ hZkyrOsizHVpgWRp4HQAi8U9Qb/5++v0YBdLBd/xt9oCJTAtsS/o0lTytM4hfwo9/SyU2 dIbAosPgrDcgvdw+fwxHoqDIYgajjS7rGudZIMntQ5qvGSDGLe3KT6ZXwD9dc8zqu3gqC Gq0zX8V50SBiEW8JbNhzoXTwEaTTewI7L3FiMEPxXWMu8Vs/ibUUY1jsIJaefqkdk/vzK MBUrpA6fy8dghygEUORI4R7AYbBhHdKoHrLqW93wPTmXAlZSCZYs3QozbKl+VfhSMOg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796385920; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=pw6llO3F5GjfLjW20l+41VbtBRNNBSQ81ZVkWy6TdlQ=; b=fN5N4P4LIauiNSRvmf4oZ4ugcI/5JLZ366ULs2bBTBHAxWXBtJ7MiaCAxystSKum6MK8 0fs9lAd6rvffHekLXcYFC6kpTHADg3PgiQ0MRsGrXkslI8DjZhtvHouQVj4eEpGD4oIHC npBxMCSSW+m+NQPsugvXWjuCqikB4FXuZDpGNY6hhQ4sdtltrkojKJxxtxmWUj0k4AY6k spRjtcfeAYXARhilG7YUyD3Lqd1d+yHhOZPObnmtzgDdtVN5Ag4U3J6VPj7jPzu9zwk/y iYSWi8AyvfZb1/6VAjU7uUGUnTH6sV1RX7iOaIERfxsSKsSWCJTgFrPPCQmj+oQ+tew== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=syBeuNBl; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BDBB4606A322; Fri, 4 Dec 2026 12:05:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=syBeuNBl Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3BC6C1F0092C; Fri, 4 Dec 2026 12:05:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796385920; bh=pw6llO3F5GjfLjW20l+41VbtBRNNBSQ81ZVkWy6TdlQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=syBeuNBlFa2oBKeV+pFI+2ykkH+SjYTAR7WUDN3yylzsL3MzhcC6mj8Q7JBj/kPvL ygAQtGkJPvnbFlAjYixvBV+TN70PlSK3QFfPeCA7JS1jO89j5V0avG8u5qx8fr5rlQ z0fGgT3VuBDUuUdosoilrZ1RrbhnF14gn7Uy29Q0= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Zhao Feng , Guenter Roeck , Sasha Levin Subject: [PATCH 6.6 0747/1167] watchdog: npcm: fix clock prepare leak when setting timeout on a running watchdog Date: Fri, 4 Dec 2026 19:02:54 +0900 Message-ID: <20261204100721.523861392@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100702.047403948@linuxfoundation.org> References: <20261204100702.047403948@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zhao Feng [ Upstream commit 57c7cbe21acc77291ec0fbdd4bd72aa259cf4986 ] npcm_wdt_start() unconditionally prepares and enables the watchdog clock, and npcm_wdt_stop() is the only place that disables it. npcm_wdt_set_timeout() calls npcm_wdt_start() again whenever the watchdog is already active, so every WDIOC_SETTIMEOUT ioctl issued while the watchdog is running takes one extra clock prepare/enable reference that is never dropped. Split the register programming out of npcm_wdt_start() into a __npcm_wdt_start() helper that assumes the clock is already running, and call the helper from npcm_wdt_set_timeout() instead; only the watchdog .start callback (and the restart path, which intentionally keeps the clock) now acquires the clock. Fixes: af084fdccfaf ("watchdog: npcm: Enable clock if provided") Cc: stable@vger.kernel.org Signed-off-by: Zhao Feng Link: https://patch.msgid.link/20261109071004.1506-1-zhaofeng2@cmss.chinamobile.com Signed-off-by: Guenter Roeck Signed-off-by: Sasha Levin --- drivers/watchdog/npcm_wdt.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/watchdog/npcm_wdt.c b/drivers/watchdog/npcm_wdt.c index e62ea054bc618..aff1ea1e6b62d 100644 --- a/drivers/watchdog/npcm_wdt.c +++ b/drivers/watchdog/npcm_wdt.c @@ -63,13 +63,11 @@ static int npcm_wdt_ping(struct watchdog_device *wdd) return 0; } -static int npcm_wdt_start(struct watchdog_device *wdd) +static void __npcm_wdt_start(struct watchdog_device *wdd) { struct npcm_wdt *wdt = to_npcm_wdt(wdd); u32 val; - clk_prepare_enable(wdt->clk); - if (wdd->timeout < 2) val = 0x800; else if (wdd->timeout < 3) @@ -94,6 +92,15 @@ static int npcm_wdt_start(struct watchdog_device *wdd) val |= NPCM_WTRE | NPCM_WTE | NPCM_WTR | NPCM_WTIE; writel(val, wdt->reg); +} + +static int npcm_wdt_start(struct watchdog_device *wdd) +{ + struct npcm_wdt *wdt = to_npcm_wdt(wdd); + + clk_prepare_enable(wdt->clk); + + __npcm_wdt_start(wdd); return 0; } @@ -134,7 +141,7 @@ static int npcm_wdt_set_timeout(struct watchdog_device *wdd, wdd->timeout = 2750; if (watchdog_active(wdd)) - npcm_wdt_start(wdd); + __npcm_wdt_start(wdd); return 0; } -- 2.53.0