[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <yhcdgillcnlwditdmitklbhkfd2lh5on7ibvuqdxnhricjoele@c246pnf4uc42>
Date: Mon, 28 Apr 2025 19:00:18 +0200
From: Uwe Kleine-König <u.kleine-koenig@...libre.com>
To: Alexandre Mergnat <amergnat@...libre.com>
Cc: Alexandre Belloni <alexandre.belloni@...tlin.com>,
Baolin Wang <baolin.wang@...ux.alibaba.com>, linux-rtc@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v4 2/5] rtc: Fix offset calculation for .start_secs < 0
Hello,
On Mon, Apr 28, 2025 at 12:06:48PM +0200, Alexandre Mergnat wrote:
> 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: 989515647e783 ("rtc: Add one offset seconds to expand RTC range")
> Signed-off-by: Alexandre Mergnat <amergnat@...libre.com>
Reviewed-by: Uwe Kleine-König <u.kleine-koenig@...libre.com>
Thanks
Uwe
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists