mmc: cavium: Fix a shift wrapping bug
authorDan Carpenter <dan.carpenter@oracle.com>
Thu, 13 Apr 2017 19:47:48 +0000 (22:47 +0300)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 24 Apr 2017 19:42:23 +0000 (21:42 +0200)
"dat" is a u64 and "shift" starts as 54 so this is a shift wrapping bug.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/cavium.c

index d89c2ebcad90d773d1c94c2f3cfe15e87ee8c63f..d89c011bbea8bf334329ffd836ba94722899f775 100644 (file)
@@ -733,7 +733,7 @@ static void do_write_request(struct cvm_mmc_host *host, struct mmc_request *mrq)
                }
 
                while (smi->consumed < smi->length && shift >= 0) {
-                       dat |= ((u8 *)smi->addr)[smi->consumed] << shift;
+                       dat |= (u64)((u8 *)smi->addr)[smi->consumed] << shift;
                        bytes_xfered++;
                        smi->consumed++;
                        shift -= 8;