瀏覽代碼

IB/hfi1: Use QPN mask to avoid overflow

Ensure we can't come up with an array size that is bigger than the array
by applying the QPN mask before the divide in the free_qpn function.

Reviewed-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>
Dennis Dalessandro 8 年之前
父節點
當前提交
6c31e5283c
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      drivers/infiniband/sw/rdmavt/qp.c

+ 1 - 1
drivers/infiniband/sw/rdmavt/qp.c

@@ -645,7 +645,7 @@ static void rvt_free_qpn(struct rvt_qpn_table *qpt, u32 qpn)
 {
 	struct rvt_qpn_map *map;
 
-	map = qpt->map + qpn / RVT_BITS_PER_PAGE;
+	map = qpt->map + (qpn & RVT_QPN_MASK) / RVT_BITS_PER_PAGE;
 	if (map->page)
 		clear_bit(qpn & RVT_BITS_PER_PAGE_MASK, map->page);
 }