Commit 4ad79d38 authored by Chengchang Tang's avatar Chengchang Tang Committed by Jeiwei Li
Browse files

RDMA/hns: Fix signed-unsigned mix with relational

driver inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I87LLN



--------------------------------------------------------------------------

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: 30b70788 ("RDMA/hns: Support inline data in extented sge space for RC")
Signed-off-by: default avatarChengchang Tang <tangchengchang@huawei.com>
parent d97ffe85
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -282,7 +282,7 @@ static bool check_inl_data_len(struct hns_roce_qp *qp, unsigned int len)
	struct hns_roce_dev *hr_dev = to_hr_dev(qp->ibqp.device);
	int mtu = ib_mtu_enum_to_int(qp->path_mtu);

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