Shifting by equal to or bigger than the width of a type results in undefined behavior. By using a wide enough temporary variable the issue can be avoided. Signed-off-by: Guillermo O. Freschi <kedrot@xxxxxxxxx> --- drivers/staging/wilc1000/host_interface.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/staging/wilc1000/host_interface.c b/drivers/staging/wilc1000/host_interface.c index f7c22d7b28d1..4591b1452df4 100644 --- a/drivers/staging/wilc1000/host_interface.c +++ b/drivers/staging/wilc1000/host_interface.c @@ -2407,6 +2407,7 @@ static void Handle_SetMulticastFilter(struct wilc_vif *vif, s32 result = 0; struct wid wid; u8 *pu8CurrByte; + u32 enabled; wid.id = (u16)WID_SETUP_MULTICAST_FILTER; wid.type = WID_BIN; @@ -2416,10 +2417,12 @@ static void Handle_SetMulticastFilter(struct wilc_vif *vif, goto ERRORHANDLER; pu8CurrByte = wid.val; - *pu8CurrByte++ = (strHostIfSetMulti->enabled & 0xFF); - *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 8) & 0xFF); - *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 16) & 0xFF); - *pu8CurrByte++ = ((strHostIfSetMulti->enabled >> 24) & 0xFF); + + enabled = strHostIfSetMulti->enabled; + *pu8CurrByte++ = (enabled & 0xFF); + *pu8CurrByte++ = ((enabled >> 8) & 0xFF); + *pu8CurrByte++ = ((enabled >> 16) & 0xFF); + *pu8CurrByte++ = ((enabled >> 24) & 0xFF); *pu8CurrByte++ = (strHostIfSetMulti->cnt & 0xFF); *pu8CurrByte++ = ((strHostIfSetMulti->cnt >> 8) & 0xFF); -- 2.11.0