From patchwork Fri Apr 29 07:21:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 93399 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 897B01007DB for ; Fri, 29 Apr 2011 17:20:11 +1000 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755353Ab1D2HUE (ORCPT ); Fri, 29 Apr 2011 03:20:04 -0400 Received: from vpn.id2.novell.com ([195.33.99.129]:46939 "EHLO vpn.id2.novell.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754475Ab1D2HUD convert rfc822-to-8bit (ORCPT ); Fri, 29 Apr 2011 03:20:03 -0400 Received: from EMEA1-MTA by vpn.id2.novell.com with Novell_GroupWise; Fri, 29 Apr 2011 08:20:00 +0100 Message-Id: <4DBA830A020000780003ED5D@vpn.id2.novell.com> X-Mailer: Novell GroupWise Internet Agent 8.0.1 Date: Fri, 29 Apr 2011 08:21:14 +0100 From: "Jan Beulich" To: Cc: , "Jeff Mahoney" , Subject: [PATCH] bridge: Module use count must be updated as bridges are created/destroyed Mime-Version: 1.0 Content-Disposition: inline Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Otherwise 'modprobe -r' on a module having a dependency on bridge will implicitly unload bridge, bringing down all connectivity that was using bridges. Signed-off-by: Jan Beulich Cc: Jeff Mahoney --- net/bridge/br_if.c | 9 +++++++++ 1 file changed, 9 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- 2.6.39-rc5/net/bridge/br_if.c +++ 2.6.39-rc5-bridge-module-get-put/net/bridge/br_if.c @@ -290,6 +290,11 @@ int br_add_bridge(struct net *net, const if (!dev) return -ENOMEM; + if (!try_module_get(THIS_MODULE)) { + free_netdev(dev); + return -ENOENT; + } + rtnl_lock(); if (strchr(dev->name, '%')) { ret = dev_alloc_name(dev, dev->name); @@ -308,6 +313,8 @@ int br_add_bridge(struct net *net, const unregister_netdevice(dev); out: rtnl_unlock(); + if (ret) + module_put(THIS_MODULE); return ret; out_free: @@ -339,6 +346,8 @@ int br_del_bridge(struct net *net, const del_br(netdev_priv(dev), NULL); rtnl_unlock(); + if (ret == 0) + module_put(THIS_MODULE); return ret; }