mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-02 15:18:19 +00:00
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: 30b707886a
("RDMA/hns: Support inline data in extented sge space for RC")
Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Junxian Huang <huangjunxian6@hisilicon.com>
Link: https://lore.kernel.org/r/20231017125239.164455-4-huangjunxian6@hisilicon.com
Signed-off-by: Leon Romanovsky <leon@kernel.org>
This commit is contained in:
parent
c64e9710f9
commit
b5f9efff10
1 changed files with 1 additions and 1 deletions
|
@ -270,7 +270,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);
|
||||
|
|
Loading…
Reference in a new issue