Commit c6d6af3d authored by Junxian Huang's avatar Junxian Huang Committed by Chengchang Tang
Browse files

RDMA/hns: Fix dereference of noderef expression

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



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

Fix sparse warnings: dereference of noderef expression. This is because
curr_active_slave is defined as:

struct bonding {
	...
	struct   slave __rcu *curr_active_slave;
	...
};

__rcu contains __attribute__((noderef)) inside, which disallows callers
dereferece it directly.

Fixes: 2004b3f9 ("RDMA/hns: Support RoCE bonding")
Signed-off-by: default avatarJunxian Huang <huangjunxian6@hisilicon.com>
Signed-off-by: default avatarXinghai Cen <cenxinghai@h-partners.com>
parent 053bf134
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -93,10 +93,16 @@ bool hns_roce_bond_is_active(struct hns_roce_dev *hr_dev)
static inline bool is_active_slave(struct net_device *net_dev,
				   struct hns_roce_bond_group *bond_grp)
{
	struct net_device *slave_dev;

	if (!bond_grp || !bond_grp->bond || !bond_grp->bond->curr_active_slave)
		return false;

	return net_dev == bond_grp->bond->curr_active_slave->dev;
	rcu_read_lock();
	slave_dev = bond_option_active_slave_get_rcu(bond_grp->bond);
	rcu_read_unlock();

	return net_dev == slave_dev;
}

struct net_device *hns_roce_get_bond_netdev(struct hns_roce_dev *hr_dev)