Re: [PATCH] mmc: cavium: Fix a shift wrapping bug

Ulf Hansson
2017-04-18T19:15:51Z

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;