]> git.baikalelectronics.ru Git - kernel.git/commit
IB/hfi1: Add a safe wrapper for _rcd_get_by_index
authorMichael J. Ruhl <michael.j.ruhl@intel.com>
Tue, 26 Sep 2017 14:01:16 +0000 (07:01 -0700)
committerDoug Ledford <dledford@redhat.com>
Wed, 27 Sep 2017 15:34:13 +0000 (11:34 -0400)
commit936e6f160616c5f1f504e005a3a86cc97c171ee0
tree3a4a01a21e117dac7c3ea8d1d64f07e9c7b600a1
parenta68485e8e8af0660422e2ed0cfc52d132d4c4e0b
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>
drivers/infiniband/hw/hfi1/chip.c
drivers/infiniband/hw/hfi1/debugfs.c
drivers/infiniband/hw/hfi1/driver.c
drivers/infiniband/hw/hfi1/hfi.h
drivers/infiniband/hw/hfi1/init.c