diff options
author | Michael J. Ruhl <michael.j.ruhl@intel.com> | 2017-09-26 17:01:16 +0300 |
---|---|---|
committer | Doug Ledford <dledford@redhat.com> | 2017-09-27 18:34:13 +0300 |
commit | d59075ad1e091cdb663974b10c8bac5491acc356 (patch) | |
tree | 3a4a01a21e117dac7c3ea8d1d64f07e9c7b600a1 /drivers/infiniband/hw/hfi1/driver.c | |
parent | 442e55661db1d5833b0eb5b85f78a845ace7a7cc (diff) | |
download | linux-d59075ad1e091cdb663974b10c8bac5491acc356.tar.xz |
IB/hfi1: Add a safe wrapper for _rcd_get_by_index
hfi1_rcd_get_by_index assumes that the given index is in the correct
range. In most cases this is correct because the index is bounded by
a loop. For these cases, adding a range check to the function is
redundant.
For the use case that is not bounded by the loop range, a _safe wrapper
function is needed to validate the index before accessing the rcd array.
Add a _safe wrapper to _get_by_index to validate the index range.
Update appropriate call sites with the new _safe function.
Reviewed-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
Diffstat (limited to 'drivers/infiniband/hw/hfi1/driver.c')
-rw-r--r-- | drivers/infiniband/hw/hfi1/driver.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/infiniband/hw/hfi1/driver.c b/drivers/infiniband/hw/hfi1/driver.c index 7372cc00cb2d..85a425ef740e 100644 --- a/drivers/infiniband/hw/hfi1/driver.c +++ b/drivers/infiniband/hw/hfi1/driver.c @@ -866,7 +866,7 @@ static inline void set_nodma_rtail(struct hfi1_devdata *dd, u16 ctxt) * interrupt handler for all statically allocated kernel contexts. */ if (ctxt >= dd->first_dyn_alloc_ctxt) { - rcd = hfi1_rcd_get_by_index(dd, ctxt); + rcd = hfi1_rcd_get_by_index_safe(dd, ctxt); if (rcd) { rcd->do_interrupt = &handle_receive_interrupt_nodma_rtail; @@ -895,7 +895,7 @@ static inline void set_dma_rtail(struct hfi1_devdata *dd, u16 ctxt) * interrupt handler for all statically allocated kernel contexts. */ if (ctxt >= dd->first_dyn_alloc_ctxt) { - rcd = hfi1_rcd_get_by_index(dd, ctxt); + rcd = hfi1_rcd_get_by_index_safe(dd, ctxt); if (rcd) { rcd->do_interrupt = &handle_receive_interrupt_dma_rtail; |