diff mbox

mmc: cavium: Fix a shift wrapping bug

Message ID 20170413194748.GE591@mwanda (mailing list archive)
State New, archived
Headers show

Commit Message

Dan Carpenter April 13, 2017, 7:47 p.m. UTC
"dat" is a u64 and "shift" starts as 54 so this is a shift wrapping bug.

Fixes: 8047c753f3d3 ("mmc: cavium: Add core MMC driver for Cavium SOCs")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Ulf Hansson April 18, 2017, 7:15 p.m. UTC | #1
On 13 April 2017 at 21:47, Dan Carpenter <dan.carpenter@oracle.com> wrote:
> "dat" is a u64 and "shift" starts as 54 so this is a shift wrapping bug.
>
> Fixes: 8047c753f3d3 ("mmc: cavium: Add core MMC driver for Cavium SOCs")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thanks, applied for next!

Kind regards
Uffe

>
> diff --git a/drivers/mmc/host/cavium.c b/drivers/mmc/host/cavium.c
> index d842b6986189..54ff1363b564 100644
> --- a/drivers/mmc/host/cavium.c
> +++ b/drivers/mmc/host/cavium.c
> @@ -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;
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/mmc/host/cavium.c b/drivers/mmc/host/cavium.c
index d842b6986189..54ff1363b564 100644
--- a/drivers/mmc/host/cavium.c
+++ b/drivers/mmc/host/cavium.c
@@ -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;