From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: Frank Li <Frank.Li@nxp.com>, Thomas Gleixner <tglx@linutronix.de>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
Dong Aisheng <aisheng.dong@nxp.com>,
"open list:CLOCKSOURCE,
CLOCKEVENT DRIVERS" <linux-kernel@vger.kernel.org>,
"open list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE"
<imx@lists.linux.dev>,
"moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE"
<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH 1/2] clocksource: imx-tpm: fix return -ETIME when delta exceeds INT_MAX
Date: Mon, 2 Sep 2024 11:29:48 +0200 [thread overview]
Message-ID: <66b8c478-44c4-46b2-a029-bbf847429e2b@linaro.org> (raw)
In-Reply-To: <20240725193355.1436005-1-Frank.Li@nxp.com>
On 25/07/2024 21:33, Frank Li wrote:
> From: Jacky Bai <ping.bai@nxp.com>
>
> In tpm_set_next_event(delta), return -ETIME by wrong cast to int when delta
> is larger than INT_MAX.
>
> For example:
>
> tpm_set_next_event(delta = 0xffff_fffe)
> {
> ...
> next = tpm_read_counter(); // assume next is 0x10
> next += delta; // next will 0xffff_fffe + 0x10 = 0x1_0000_000e
> now = tpm_read_counter(); // now is 0x10
> ...
>
> return (int)(next - now) <= 0 ? -ETIME : 0;
> ^^^^^^^^^^
> 0x1_0000_000e - 0x10 = 0xffff_fffe, which is -2 when
> cast to int. So return -ETIME.
> }
>
> To fix this, introduce a 'prev' variable and check if 'now - prev' is
> larger than delta.
>
> Cc: <stable@vger.kernel.org>
> Fixes: 059ab7b82eec ("clocksource/drivers/imx-tpm: Add imx tpm timer support")
> Signed-off-by: Jacky Bai <ping.bai@nxp.com>
> Reviewed-by: Peng Fan <peng.fan@nxp.com>
> Reviewed-by: Ye Li <ye.li@nxp.com>
> Reviewed-by: Jason Liu <jason.hui.liu@nxp.com>
> Signed-off-by: Frank Li <Frank.Li@nxp.com>
> ---
Applied, thanks
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
next prev parent reply other threads:[~2024-09-02 9:29 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-25 19:33 Frank Li
2024-07-25 19:33 ` [PATCH 2/2] clocksource: imx-tpm: fix next event not taking effect sometime Frank Li
2024-09-02 10:02 ` [tip: timers/urgent] clocksource/drivers/imx-tpm: Fix " tip-bot2 for Jacky Bai
2024-08-14 16:47 ` [PATCH 1/2] clocksource: imx-tpm: fix return -ETIME when delta exceeds INT_MAX Frank Li
2024-08-19 13:21 ` Daniel Lezcano
2024-08-19 18:43 ` Frank Li
2024-08-21 7:20 ` Jacky Bai (OSS)
2024-09-02 9:29 ` Daniel Lezcano [this message]
2024-09-02 10:02 ` [tip: timers/urgent] clocksource/drivers/imx-tpm: Fix " tip-bot2 for Jacky Bai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=66b8c478-44c4-46b2-a029-bbf847429e2b@linaro.org \
--to=daniel.lezcano@linaro.org \
--cc=Frank.Li@nxp.com \
--cc=aisheng.dong@nxp.com \
--cc=festevam@gmail.com \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@kernel.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®