Skip to content

Commit 91647f4

Browse files
Dennis Dalessandrodledford
authored andcommitted
IB/hfi1: Ensure dd->gi_mask can not be overflowed
As the code stands today the array access in remap_intr() is OK. To future proof the code though we should explicitly check to ensure the index value is not outside of the valid range. This is not a straight forward calculation so err on the side of caution. Reviewed-by: Michael J. Ruhl <[email protected]> Signed-off-by: Dennis Dalessandro <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent 3d886aa commit 91647f4

File tree

1 file changed

+6
-1
lines changed
  • drivers/infiniband/hw/hfi1

1 file changed

+6
-1
lines changed

drivers/infiniband/hw/hfi1/chip.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12847,7 +12847,12 @@ static void remap_intr(struct hfi1_devdata *dd, int isrc, int msix_intr)
1284712847
/* clear from the handled mask of the general interrupt */
1284812848
m = isrc / 64;
1284912849
n = isrc % 64;
12850-
dd->gi_mask[m] &= ~((u64)1 << n);
12850+
if (likely(m < CCE_NUM_INT_CSRS)) {
12851+
dd->gi_mask[m] &= ~((u64)1 << n);
12852+
} else {
12853+
dd_dev_err(dd, "remap interrupt err\n");
12854+
return;
12855+
}
1285112856

1285212857
/* direct the chip source to the given MSI-X interrupt */
1285312858
m = isrc / 8;

0 commit comments

Comments
 (0)