From patchwork Fri Aug 30 10:04: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: 271214 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 5D7172C009A for ; Fri, 30 Aug 2013 20:08:38 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752684Ab3H3KId (ORCPT ); Fri, 30 Aug 2013 06:08:33 -0400 Received: from szxga01-in.huawei.com ([119.145.14.64]:29793 "EHLO szxga01-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752090Ab3H3KId (ORCPT ); Fri, 30 Aug 2013 06:08:33 -0400 Received: from 172.24.2.119 (EHLO szxeml212-edg.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.4-GA FastPath queued) with ESMTP id BHM77873; Fri, 30 Aug 2013 18:05:06 +0800 (CST) Received: from SZXEML455-HUB.china.huawei.com (10.82.67.198) by szxeml212-edg.china.huawei.com (172.24.2.181) with Microsoft SMTP Server (TLS) id 14.1.323.7; Fri, 30 Aug 2013 18:05:05 +0800 Received: from [127.0.0.1] (10.135.72.199) by SZXEML455-HUB.china.huawei.com (10.82.67.198) with Microsoft SMTP Server id 14.1.323.7; Fri, 30 Aug 2013 18:05:01 +0800 Message-ID: <52206E49.3000607@huawei.com> Date: Fri, 30 Aug 2013 18:04:57 +0800 From: Ding Tianhong User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:17.0) Gecko/20130801 Thunderbird/17.0.8 MIME-Version: 1.0 To: Jay Vosburgh , Andy Gospodarek , "David S. Miller" , Nikolay Aleksandrov , Veaceslav Falico , Netdev Subject: [PATCH net-next 4/6] bonding: add rtnl lock for bonding_store_xmit_hash 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_xmit_hash() could update bond's xmit_policy, and the xmit_policy is used in xmit path for xor mode, maybe it is hard to occur any problem, but just follow the logic "don't change anything slave-related without rtnl", so I think the rntl lock is fit here. :) Signed-off-by: Ding Tianhong Cc: Nikolay Aleksandrov --- drivers/net/bonding/bond_sysfs.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c index 0f539de..deb1d8e 100644 --- a/drivers/net/bonding/bond_sysfs.c +++ b/drivers/net/bonding/bond_sysfs.c @@ -382,6 +382,9 @@ static ssize_t bonding_store_xmit_hash(struct device *d, int new_value, ret = count; struct bonding *bond = to_bond(d); + if (!rtnl_trylock()) + return restart_syscall(); + new_value = bond_parse_parm(buf, xmit_hashtype_tbl); if (new_value < 0) { pr_err("%s: Ignoring invalid xmit hash policy value %.*s.\n", @@ -396,6 +399,7 @@ static ssize_t bonding_store_xmit_hash(struct device *d, xmit_hashtype_tbl[new_value].modename, new_value); } + rtnl_unlock(); return ret; } static DEVICE_ATTR(xmit_hash_policy, S_IRUGO | S_IWUSR,