Skip to content

Commit f7b4263

Browse files
mjruhldledford
authored andcommitted
IB/hfi1: Ensure VL index is within bounds
Improve the safety of the code and ensure the array cannot be indexed out of bounds when picking the CPU for a given SDMA engine. Reviewed-by: Dennis Dalessandro <[email protected]> Signed-off-by: Michael J. Ruhl <[email protected]> Signed-off-by: Dennis Dalessandro <[email protected]> Signed-off-by: Doug Ledford <[email protected]>
1 parent 44dcfa4 commit f7b4263

File tree

1 file changed

+5
-0
lines changed
  • drivers/infiniband/hw/hfi1

1 file changed

+5
-0
lines changed

drivers/infiniband/hw/hfi1/sdma.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,11 @@ ssize_t sdma_set_cpu_to_sde_map(struct sdma_engine *sde, const char *buf,
962962
continue;
963963
}
964964

965+
if (vl >= ARRAY_SIZE(rht_node->map)) {
966+
ret = -EINVAL;
967+
goto out;
968+
}
969+
965970
rht_node = rhashtable_lookup_fast(dd->sdma_rht, &cpu,
966971
sdma_rht_params);
967972
if (!rht_node) {

0 commit comments

Comments
 (0)