Skip to content

Commit

Permalink
IB/hfi1: Fix the size parameter to find_first_bit
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Christophe Jaillet authored and Doug Ledford committed Sep 2, 2016
1 parent fffd687 commit 6aaa382
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions drivers/infiniband/hw/hfi1/mad.c
Original file line number Diff line number Diff line change
Expand Up @@ -2638,7 +2638,7 @@ static int pma_get_opa_datacounters(struct opa_pma_mad *pmp,
*/
port_mask = be64_to_cpu(req->port_select_mask[3]);
port_num = find_first_bit((unsigned long *)&port_mask,
sizeof(port_mask));
sizeof(port_mask) * 8);

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

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

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

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

0 comments on commit 6aaa382

Please sign in to comment.