Skip to content

Commit

Permalink
net/sfc/base: fix shift by more bits than field width
Browse files Browse the repository at this point in the history
This was probably an oversight when support for multiple sensor pages
was added.

Despite being undefined behaviour in C, it probably worked on Intel
x32/x64 as on them bit shift operations wrap round.

Fixes: dfb3b1c ("net/sfc/base: import monitors access via MCDI")
Cc: stable@dpdk.org

Signed-off-by: Mark Spender <mspender@solarflare.com>
Signed-off-by: Andrew Rybchenko <arybchenko@solarflare.com>
  • Loading branch information
Mark Spender authored and Ferruh Yigit committed Jun 20, 2019
1 parent b69259c commit 1dcd3a9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/net/sfc/base/mcdi_mon.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ mcdi_mon_decode_stats(
/* This sensor is one of the page boundary bits. */
}

if (~(sensor_mask[page]) & (1U << sensor))
if (~(sensor_mask[page]) &
(1U << (sensor % (sizeof (sensor_mask[page]) * 8))))
continue;
/* This sensor not in DMA buffer */

Expand Down

0 comments on commit 1dcd3a9

Please sign in to comment.