]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.8.5/mmc-sdhci-cast-unsigned-int-to-unsigned-long-long-to-avoid-unexpeted-error.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.8.5 / mmc-sdhci-cast-unsigned-int-to-unsigned-long-long-to-avoid-unexpeted-error.patch
1 From 02265cd60335a2c1417abae4192611e1fc05a6e5 Mon Sep 17 00:00:00 2001
2 From: Haibo Chen <haibo.chen@nxp.com>
3 Date: Mon, 17 Oct 2016 10:18:37 +0200
4 Subject: mmc: sdhci: cast unsigned int to unsigned long long to avoid unexpeted error
5
6 From: Haibo Chen <haibo.chen@nxp.com>
7
8 commit 02265cd60335a2c1417abae4192611e1fc05a6e5 upstream.
9
10 Potentially overflowing expression 1000000 * data->timeout_clks with
11 type unsigned int is evaluated using 32-bit arithmetic, and then used
12 in a context that expects an expression of type unsigned long long.
13
14 To avoid overflow, cast 1000000U to type unsigned long long.
15 Special thanks to Coverity.
16
17 Fixes: 7f05538af71c ("mmc: sdhci: fix data timeout (part 2)")
18 Signed-off-by: Haibo Chen <haibo.chen@nxp.com>
19 Acked-by: Adrian Hunter <adrian.hunter@intel.com>
20 Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
21 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
22
23 ---
24 drivers/mmc/host/sdhci.c | 2 +-
25 1 file changed, 1 insertion(+), 1 deletion(-)
26
27 --- a/drivers/mmc/host/sdhci.c
28 +++ b/drivers/mmc/host/sdhci.c
29 @@ -687,7 +687,7 @@ static u8 sdhci_calc_timeout(struct sdhc
30 * host->clock is in Hz. target_timeout is in us.
31 * Hence, us = 1000000 * cycles / Hz. Round up.
32 */
33 - val = 1000000 * data->timeout_clks;
34 + val = 1000000ULL * data->timeout_clks;
35 if (do_div(val, host->clock))
36 target_timeout++;
37 target_timeout += val;