Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 689c96cc authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller
Browse files

bonding: bond_slave_info_query() fix



bond_slave_info_query() should keep a read lock while accessing slave info,
or risk accessing stale data and corruption.

Signed-off-by: default avatarEric Dumazet <dada1@cosmosbay.com>
Signed-off-by: default avatarJay Vosburgh <fubar@us.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 00b64f2a
Loading
Loading
Loading
Loading
+7 −16
Original line number Diff line number Diff line
@@ -2213,33 +2213,24 @@ static int bond_slave_info_query(struct net_device *bond_dev, struct ifslave *in
{
	struct bonding *bond = netdev_priv(bond_dev);
	struct slave *slave;
	int i, found = 0;

	if (info->slave_id < 0) {
		return -ENODEV;
	}
	int i, res = -ENODEV;

	read_lock(&bond->lock);

	bond_for_each_slave(bond, slave, i) {
		if (i == (int)info->slave_id) {
			found = 1;
			break;
		}
	}

	read_unlock(&bond->lock);

	if (found) {
			res = 0;
			strcpy(info->slave_name, slave->dev->name);
			info->link = slave->link;
			info->state = slave->state;
			info->link_failure_count = slave->link_failure_count;
	} else {
		return -ENODEV;
			break;
		}
	}

	return 0;
	read_unlock(&bond->lock);

	return res;
}

/*-------------------------------- Monitoring -------------------------------*/