From patchwork Sat Jul 20 07:23:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ding Tianhong X-Patchwork-Id: 260419 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id D87B42C00A4 for ; Sat, 20 Jul 2013 17:24:31 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753841Ab3GTHY3 (ORCPT ); Sat, 20 Jul 2013 03:24:29 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:25410 "EHLO szxga02-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753774Ab3GTHYR (ORCPT ); Sat, 20 Jul 2013 03:24:17 -0400 Received: from 172.24.2.119 (EHLO szxeml213-edg.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.4-GA FastPath queued) with ESMTP id BEW38588; Sat, 20 Jul 2013 15:24:04 +0800 (CST) Received: from szxeml459-hub.china.huawei.com (10.82.67.202) by szxeml213-edg.china.huawei.com (172.24.2.30) with Microsoft SMTP Server (TLS) id 14.1.323.7; Sat, 20 Jul 2013 15:24:02 +0800 Received: from [127.0.0.1] (10.135.72.199) by szxeml459-hub.china.huawei.com (10.82.67.202) with Microsoft SMTP Server id 14.1.323.7; Sat, 20 Jul 2013 15:23:58 +0800 Message-ID: <51EA3B0D.7020501@huawei.com> Date: Sat, 20 Jul 2013 15:23:57 +0800 From: Ding Tianhong User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130620 Thunderbird/17.0.7 MIME-Version: 1.0 To: Jay Vosburgh , Andy Gospodarek , "David S. Miller" , Netdev Subject: [PATCH 3/4] bonding: the calling of bond->slave_cnt need protection X-Originating-IP: [10.135.72.199] X-CFilter-Loop: Reflected Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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 --- 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) {