Skip to content

Commit 36397b9

Browse files
Chengchang Tangrleon
authored andcommitted
RDMA/hns: Fix undifined behavior caused by invalid max_sge
If max_sge has been set to 0, roundup_pow_of_two() in set_srq_basic_param() may have undefined behavior. Fixes: 9dd0524 ("RDMA/hns: Allocate one more recv SGE for HIP08") Signed-off-by: Chengchang Tang <[email protected]> Signed-off-by: Junxian Huang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Leon Romanovsky <[email protected]>
1 parent 24c6291 commit 36397b9

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/infiniband/hw/hns/hns_roce_srq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ static int set_srq_basic_param(struct hns_roce_srq *srq,
297297

298298
max_sge = proc_srq_sge(hr_dev, srq, !!udata);
299299
if (attr->max_wr > hr_dev->caps.max_srq_wrs ||
300-
attr->max_sge > max_sge) {
300+
attr->max_sge > max_sge || !attr->max_sge) {
301301
ibdev_err(&hr_dev->ib_dev,
302302
"invalid SRQ attr, depth = %u, sge = %u.\n",
303303
attr->max_wr, attr->max_sge);

0 commit comments

Comments
 (0)