Files
Alexandre Mergnat 57082e0300 rtc: Fix offset calculation for .start_secs < 0
commit fe9f5f96cf upstream.

The comparison

        rtc->start_secs > rtc->range_max

has a signed left-hand side and an unsigned right-hand side.
So the comparison might become true for negative start_secs which is
interpreted as a (possibly very large) positive value.

As a negative value can never be bigger than an unsigned value
the correct representation of the (mathematical) comparison

        rtc->start_secs > rtc->range_max

in C is:

        rtc->start_secs >= 0 && rtc->start_secs > rtc->range_max

Use that to fix the offset calculation currently used in the
rtc-mt6397 driver.

Fixes: 989515647e ("rtc: Add one offset seconds to expand RTC range")
Signed-off-by: Alexandre Mergnat <amergnat@baylibre.com>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Link: https://lore.kernel.org/r/20250428-enable-rtc-v4-2-2b2f7e3f9349@baylibre.com
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Uwe Kleine-König <u.kleine-koenig@baylibre.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-06-10 07:15:56 -04:00
..
2024-09-27 08:18:43 -07:00
2025-01-13 23:07:18 +01:00
2022-06-24 21:24:02 +02:00
2024-01-18 01:00:21 +01:00
2023-10-15 23:01:08 +02:00
2021-04-29 23:03:26 +02:00
2024-08-28 21:54:51 +01:00
2024-11-11 11:47:58 +01:00
2025-01-29 00:42:29 +01:00
2024-11-11 22:13:39 +01:00
2025-05-29 11:12:40 +02:00
2024-05-07 23:40:10 +02:00
2024-11-25 23:32:50 +01:00
2024-09-12 00:33:24 +02:00