Skip to content

Commit 6aaa382

Browse files
tititiou36dledford
authored andcommitted
IB/hfi1: 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(u64)' which is 8. It is likely that the number of bits of 'port_mask' was expected here. Use sizeof() * 8 to get the correct number. 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> Signed-off-by: Doug Ledford <dledford@redhat.com>
1 parent fffd687 commit 6aaa382

File tree

1 file changed

+4
-4
lines changed
  • drivers/infiniband/hw/hfi1

1 file changed

+4
-4
lines changed

drivers/infiniband/hw/hfi1/mad.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2638,7 +2638,7 @@ static int pma_get_opa_datacounters(struct opa_pma_mad *pmp,
26382638
*/
26392639
port_mask = be64_to_cpu(req->port_select_mask[3]);
26402640
port_num = find_first_bit((unsigned long *)&port_mask,
2641-
sizeof(port_mask));
2641+
sizeof(port_mask) * 8);
26422642

26432643
if (port_num != port) {
26442644
pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD;
@@ -2842,7 +2842,7 @@ static int pma_get_opa_porterrors(struct opa_pma_mad *pmp,
28422842
*/
28432843
port_mask = be64_to_cpu(req->port_select_mask[3]);
28442844
port_num = find_first_bit((unsigned long *)&port_mask,
2845-
sizeof(port_mask));
2845+
sizeof(port_mask) * 8);
28462846

28472847
if (port_num != port) {
28482848
pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD;
@@ -3015,7 +3015,7 @@ static int pma_get_opa_errorinfo(struct opa_pma_mad *pmp,
30153015
*/
30163016
port_mask = be64_to_cpu(req->port_select_mask[3]);
30173017
port_num = find_first_bit((unsigned long *)&port_mask,
3018-
sizeof(port_mask));
3018+
sizeof(port_mask) * 8);
30193019

30203020
if (port_num != port) {
30213021
pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD;
@@ -3252,7 +3252,7 @@ static int pma_set_opa_errorinfo(struct opa_pma_mad *pmp,
32523252
*/
32533253
port_mask = be64_to_cpu(req->port_select_mask[3]);
32543254
port_num = find_first_bit((unsigned long *)&port_mask,
3255-
sizeof(port_mask));
3255+
sizeof(port_mask) * 8);
32563256

32573257
if (port_num != port) {
32583258
pmp->mad_hdr.status |= IB_SMP_INVALID_FIELD;

0 commit comments

Comments
 (0)