From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 5642F1F4717; Tue, 26 Aug 2025 12:58:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756213130; cv=none; b=qgruTYOoQy5jb42KGEG68U9hs52EPhzczG6YWTzK/++auK04Lwk2O0kvnsfnwV0i7CifSQMBOTCsqBkSg8q960dXXJHkzfyW2empbdst2dodp9T3wi2JsroimdoIs/rYcfGSoSys8eYkhtWYNDsXikNiA0QUdmr+DNPIW8gjHSI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756213130; c=relaxed/simple; bh=6Q7TfteDpvXvAF1n7Ud9ebO3wL45F+8oJXm8HydPijc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jZoY7mY9wPyzfF2bldaL3QmecwPH6oS5v6dVWERxA4fucodT3pXnK8ktLQ0u8HrTe5ySAliizLokLy09G6GzPMdW6rgYd1M1SflDz0n0yZDN1XtXPirtIhqcrdJt/52600cNqK4rXTta3QQMyFV7yiFiIdTcZV0Z3Jn3y027q1o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=wZqwqXo1; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="wZqwqXo1" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7EB9DC4CEF1; Tue, 26 Aug 2025 12:58:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1756213129; bh=6Q7TfteDpvXvAF1n7Ud9ebO3wL45F+8oJXm8HydPijc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wZqwqXo1WFiDPNW+UhXxfA5tnR79MA3MCP/oPPwSTmRZks4GnqflO3MOsaWuK/oVZ DwlYpD9VFHiyLgsN92GT5+S4XDiTJYoooiJ3vAeiqlKUoAJQzNhI6gftu+v7srmvK9 yCabYtUWexQaJj+OYsSTXo9fC+0PgYHYQLcvmF8E= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Ziyan Fu , Guenter Roeck , Wim Van Sebroeck , Sasha Levin Subject: [PATCH 6.6 233/587] watchdog: iTCO_wdt: Report error if timeout configuration fails Date: Tue, 26 Aug 2025 13:06:22 +0200 Message-ID: <20250826110958.862330421@linuxfoundation.org> X-Mailer: git-send-email 2.50.1 In-Reply-To: <20250826110952.942403671@linuxfoundation.org> References: <20250826110952.942403671@linuxfoundation.org> User-Agent: quilt/0.68 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Ziyan Fu [ Upstream commit 40efc43eb7ffb5a4e2f998c13b8cfb555e671b92 ] The driver probes with the invalid timeout value when 'iTCO_wdt_set_timeout()' fails, as its return value is not checked. In this case, when executing "wdctl", we may get: Device: /dev/watchdog0 Timeout: 30 seconds Timeleft: 613 seconds The timeout value is the value of "heartbeat" or "WATCHDOG_TIMEOUT", and the timeleft value is calculated from the register value we actually read (0xffff) by masking with 0x3ff and converting ticks to seconds (* 6 / 10). Add error handling to return the failure code if 'iTCO_wdt_set_timeout()' fails, ensuring the driver probe fails and prevents invalid operation. Signed-off-by: Ziyan Fu Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/20250704073518.7838-1-13281011316@163.com Signed-off-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck Signed-off-by: Sasha Levin --- drivers/watchdog/iTCO_wdt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/watchdog/iTCO_wdt.c b/drivers/watchdog/iTCO_wdt.c index dd297dcd524c..68973be2ce62 100644 --- a/drivers/watchdog/iTCO_wdt.c +++ b/drivers/watchdog/iTCO_wdt.c @@ -601,7 +601,11 @@ static int iTCO_wdt_probe(struct platform_device *pdev) /* Check that the heartbeat value is within it's range; if not reset to the default */ if (iTCO_wdt_set_timeout(&p->wddev, heartbeat)) { - iTCO_wdt_set_timeout(&p->wddev, WATCHDOG_TIMEOUT); + ret = iTCO_wdt_set_timeout(&p->wddev, WATCHDOG_TIMEOUT); + if (ret != 0) { + dev_err(dev, "Failed to set watchdog timeout (%d)\n", WATCHDOG_TIMEOUT); + return ret; + } dev_info(dev, "timeout value out of range, using %d\n", WATCHDOG_TIMEOUT); } -- 2.39.5