netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 3/4] bonding: the calling of bond->slave_cnt need protection
@ 2013-07-20  7:23 Ding Tianhong
  2013-07-20 10:47 ` [3/4] " Veaceslav Falico
  0 siblings, 1 reply; 6+ messages in thread
From: Ding Tianhong @ 2013-07-20  7:23 UTC (permalink / raw)
  To: Jay Vosburgh, Andy Gospodarek, David S. Miller, Netdev

The bonding_store_mode has rtnl protection, so no need to get read lock
for bond->slave_cnt, but the bonding_store_fail_over_mac need to protect
the bond->slave_cnt, so add read_lock().

Signed-off-by: Ding Tianhong <dingtianhong@huawei.com>
---
 drivers/net/bonding/bond_sysfs.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index dc36a3d..d01a189 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -504,11 +504,14 @@ static ssize_t bonding_store_fail_over_mac(struct device *d,
 	int new_value;
 	struct bonding *bond = to_bond(d);
 
+	read_lock(&bond->lock);
 	if (bond->slave_cnt != 0) {
 		pr_err("%s: Can't alter fail_over_mac with slaves in bond.\n",
 		       bond->dev->name);
+		read_unlock(&bond->lock);
 		return -EPERM;
 	}
+	read_unlock(&bond->lock);
 
 	new_value = bond_parse_parm(buf, fail_over_mac_tbl);
 	if (new_value < 0) {
-- 
1.8.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-07-22  0:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-20  7:23 [PATCH 3/4] bonding: the calling of bond->slave_cnt need protection Ding Tianhong
2013-07-20 10:47 ` [3/4] " Veaceslav Falico
2013-07-20 12:42   ` Nikolay Aleksandrov
2013-07-20 15:00     ` Veaceslav Falico
2013-07-22  0:47       ` Ding Tianhong
2013-07-22  0:42   ` Ding Tianhong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).