Skip to content

Commit fffd687

Browse files
tititiou36dledford
authored andcommitted
IB/mlx5: Fix the size parameter to find_first_bit
The 2nd parameter of 'find_first_bit' is the number of bits to search. In this case, we are passing 'sizeof(tmp)' which is likely to be 4 or 8 because 'tmp' is an 'unsigned long'. It is likely that the number of bits of 'tmp' was expected here. So use BITS_PER_LONG instead. It has been spotted by the following coccinelle script: @@ expression ret, x; @@ * ret = \(find_first_bit \| find_first_zero_bit\) (x, sizeof(...)); Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Acked-by: Majd Dibbiny <majd@mellanox.com> Acked-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Doug Ledford <dledford@redhat.com>
1 parent 61a28d2 commit fffd687

File tree

1 file changed

+3
-3
lines changed
  • drivers/infiniband/hw/mlx5

1 file changed

+3
-3
lines changed

drivers/infiniband/hw/mlx5/mem.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void mlx5_ib_cont_pages(struct ib_umem *umem, u64 addr, int *count, int *shift,
7171

7272
addr = addr >> page_shift;
7373
tmp = (unsigned long)addr;
74-
m = find_first_bit(&tmp, sizeof(tmp));
74+
m = find_first_bit(&tmp, BITS_PER_LONG);
7575
skip = 1 << m;
7676
mask = skip - 1;
7777
i = 0;
@@ -81,15 +81,15 @@ void mlx5_ib_cont_pages(struct ib_umem *umem, u64 addr, int *count, int *shift,
8181
for (k = 0; k < len; k++) {
8282
if (!(i & mask)) {
8383
tmp = (unsigned long)pfn;
84-
m = min_t(unsigned long, m, find_first_bit(&tmp, sizeof(tmp)));
84+
m = min_t(unsigned long, m, find_first_bit(&tmp, BITS_PER_LONG));
8585
skip = 1 << m;
8686
mask = skip - 1;
8787
base = pfn;
8888
p = 0;
8989
} else {
9090
if (base + p != pfn) {
9191
tmp = (unsigned long)p;
92-
m = find_first_bit(&tmp, sizeof(tmp));
92+
m = find_first_bit(&tmp, BITS_PER_LONG);
9393
skip = 1 << m;
9494
mask = skip - 1;
9595
base = pfn;

0 commit comments

Comments
 (0)