Skip to content

Commit b5f9eff

Browse files
Chengchang Tangrleon
authored andcommitted
RDMA/hns: Fix signed-unsigned mixed comparisons
The ib_mtu_enum_to_int() and uverbs_attr_get_len() may returns a negative value. In this case, mixed comparisons of signed and unsigned types will throw wrong results. This patch adds judgement for this situation. Fixes: 30b7078 ("RDMA/hns: Support inline data in extented sge space for RC") 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 c64e971 commit b5f9eff

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/infiniband/hw/hns/hns_roce_hw_v2.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ static bool check_inl_data_len(struct hns_roce_qp *qp, unsigned int len)
270270
struct hns_roce_dev *hr_dev = to_hr_dev(qp->ibqp.device);
271271
int mtu = ib_mtu_enum_to_int(qp->path_mtu);
272272

273-
if (len > qp->max_inline_data || len > mtu) {
273+
if (mtu < 0 || len > qp->max_inline_data || len > mtu) {
274274
ibdev_err(&hr_dev->ib_dev,
275275
"invalid length of data, data len = %u, max inline len = %u, path mtu = %d.\n",
276276
len, qp->max_inline_data, mtu);

0 commit comments

Comments
 (0)