From: Dan Carpenter Date: Fri, 6 Jul 2018 08:39:21 +0000 (+0300) Subject: Staging: Gasket: shift wrapping bug in gasket_read_modify_write_64() X-Git-Tag: v4.19~371^2~615 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c37a192ef442fc34e9aa7c9e479f20eb4cd6f7af;p=platform%2Fkernel%2Flinux-rpi.git Staging: Gasket: shift wrapping bug in gasket_read_modify_write_64() This function only has one caller so mask_width is 1 and mask_shift is 32. Shifting an int by 32 bits is undefined, but I guess on GCC it wraps to 0x1? Anyway it's supposed to be 0x100000000. Fixes: 9a69f5087ccc ("drivers/staging: Gasket driver framework + Apex driver") Signed-off-by: Dan Carpenter Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/gasket/gasket_core.h b/drivers/staging/gasket/gasket_core.h index 203b9a3..5d6535a 100644 --- a/drivers/staging/gasket/gasket_core.h +++ b/drivers/staging/gasket/gasket_core.h @@ -683,7 +683,7 @@ static inline void gasket_read_modify_write_64( u64 mask, tmp; tmp = gasket_dev_read_64(dev, bar, location); - mask = ((1 << mask_width) - 1) << mask_shift; + mask = ((1ULL << mask_width) - 1) << mask_shift; tmp = (tmp & ~mask) | (value << mask_shift); gasket_dev_write_64(dev, tmp, bar, location); }