Commit 386f263a authored by wenglianfa's avatar wenglianfa Committed by Juan Zhou
Browse files

RDMA/hns: Fix null pointer when alloc_scc_param() fails

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



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

The failure of alloc_scc_param() does not cause sysfs to be unavailable.
In this case, hr_dev->scc_param=NULL, if the user calls scc_attr_show()/
scc_attr_store(), hr_dev->scc_param is accessed and a null pointer error
is reported. To fix it, make scc_param invisible when alloc_scc_param()
fails.

Fixes: 41da9cd8 ("RDMA/hns: Support congestion control algorithm parameter configuration")
Signed-off-by: default avatarwenglianfa <wenglianfa@huawei.com>
Signed-off-by: default avatarJuan Zhou <zhoujuan51@h-partners.com>
parent 54552708
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -171,6 +171,9 @@ static umode_t scc_attr_is_visible(struct kobject *kobj,
	struct ib_device *ibdev = ib_port_sysfs_get_ibdev_kobj(kobj, &port_num);
	struct hns_roce_dev *hr_dev = to_hr_dev(ibdev);

	if (!hr_dev->scc_param)
		return 0;

	if (hr_dev->is_vf ||
	    !(hr_dev->caps.flags & HNS_ROCE_CAP_FLAG_QP_FLOW_CTRL))
		return 0;