mirror of
https://github.com/torvalds/linux.git
synced 2026-09-22 12:44:03 +02:00
mmc: omap_hsmmc: fix busy_timeout overflow in ns conversion on 32-bit
omap_hsmmc_prepare_data() converts the command busy timeout to nanoseconds
with:
timeout = req->cmd->busy_timeout * NSEC_PER_MSEC;
busy_timeout is an unsigned int (milliseconds) and timeout is a u64, but
NSEC_PER_MSEC is 1000000L. On 32-bit builds the multiplication is
performed in 32-bit arithmetic and wraps for busy_timeout values above
~4294 ms, before the result is assigned to the u64.
The driver does not set mmc->max_busy_timeout, so the core does not cap the
busy timeout, and commands such as erase or SANITIZE (MMC_SANITIZE_TIMEOUT_MS
is 240000 ms) can pass a busy_timeout far larger than 4294 ms. The wrapped,
much smaller ns value is then programmed via set_data_timeout(), so the data
timeout is set too short and the operation can time out prematurely.
Cast busy_timeout to u64 before the multiplication so the conversion is done
in 64-bit arithmetic.
Fixes: 8cc9a3e73d ("mmc: host: omap_hsmmc: use generic_cmd6_time to program timeout value for CMD6")
Cc: stable@vger.kernel.org
Signed-off-by: Zhan Xusheng <zhanxusheng@xiaomi.com>
Signed-off-by: Ulf Hansson <ulfh@kernel.org>
This commit is contained in:
parent
c125ee35a4
commit
f64ea900e4
|
|
@ -1357,7 +1357,7 @@ omap_hsmmc_prepare_data(struct omap_hsmmc_host *host, struct mmc_request *req)
|
|||
if (req->data == NULL) {
|
||||
OMAP_HSMMC_WRITE(host->base, BLK, 0);
|
||||
if (req->cmd->flags & MMC_RSP_BUSY) {
|
||||
timeout = req->cmd->busy_timeout * NSEC_PER_MSEC;
|
||||
timeout = (u64)req->cmd->busy_timeout * NSEC_PER_MSEC;
|
||||
|
||||
/*
|
||||
* Set an arbitrary 100ms data timeout for commands with
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user