]> git.ipfire.org Git - thirdparty/u-boot.git/commit
watchdog: qcom: Add max timeout check to prevent overflow
authorGopinath Sekar <gopinath.sekar@oss.qualcomm.com>
Wed, 25 Jun 2025 09:46:07 +0000 (15:16 +0530)
committerCasey Connolly <casey.connolly@linaro.org>
Wed, 14 Jan 2026 15:17:48 +0000 (16:17 +0100)
commitb2446a2314310971563c0279345bbd3293614e33
treec9bda9b7c6fa3d994747dffa398e58b46318938c
parentd503633a36767d756c7de28305cf0de79440cbc0
watchdog: qcom: Add max timeout check to prevent overflow

Added a check to ensure the requested timeout does not exceed the
hardware's maximum supported value. This prevents register overflow
and ensures watchdog reliability.

So, added a check in qcom_wdt_start() to ensure the requested timeout
does not exceed the hardware-supported maximum value. If the requested
value exceeds the maximum value, then the timeout is clamped
at maximum value.

The timeout is first converted to watchdog ticks and then compared
against QCOM_WDT_MAX_TIMEOUT. This helps prevent misconfiguration
and potential watchdog misbehavior due to overflow.

QCOM_WDT_MAX_TIMEOUT is set to 0xFFFFF, as Qualcomm SoCs typically
use 20 bits to store bark/bite timeout values.

This work builds upon the previous submission:
https://lore.kernel.org/u-boot/20250527124926.128413-1-balaji.selvanathan@oss.qualcomm.com/

Signed-off-by: Gopinath Sekar <gopinath.sekar@oss.qualcomm.com>
Reviewed-by: Stefan Roese <sr@denx.de>
Link: https://patch.msgid.link/20250625094607.1348494-1-gopinath.sekar@oss.qualcomm.com
Signed-off-by: Casey Connolly <casey.connolly@linaro.org>
drivers/watchdog/qcom-wdt.c