diff options
author | Hangbin Liu <liuhangbin@gmail.com> | 2018-04-27 20:59:24 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-05-19 10:26:57 +0200 |
commit | 0c2133c8b38c6c6ddfd2340c1aefa4844afd0e94 (patch) | |
tree | f2e5ab80e4f3e91235376ca15bc0f3d116c058ad /net | |
parent | 205cd52bbee7fe6452912fe01ceade970bccc926 (diff) |
bridge: check iface upper dev when setting master via ioctl
[ Upstream commit e8238fc2bd7b4c3c7554fa2df067e796610212fc ]
When we set a bond slave's master to bridge via ioctl, we only check
the IFF_BRIDGE_PORT flag. Although we will find the slave's real master
at netdev_master_upper_dev_link() later, it already does some settings
and allocates some resources. It would be better to return as early
as possible.
v1 -> v2:
use netdev_master_upper_dev_get() instead of netdev_has_any_upper_dev()
to check if we have a master, because not all upper devs are masters,
e.g. vlan device.
Reported-by: syzbot+de73361ee4971b6e6f75@syzkaller.appspotmail.com
Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
Acked-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/bridge/br_if.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/net/bridge/br_if.c b/net/bridge/br_if.c index ed0dd3340084..8e173324693d 100644 --- a/net/bridge/br_if.c +++ b/net/bridge/br_if.c @@ -504,8 +504,8 @@ int br_add_if(struct net_bridge *br, struct net_device *dev) if (dev->netdev_ops->ndo_start_xmit == br_dev_xmit) return -ELOOP; - /* Device is already being bridged */ - if (br_port_exists(dev)) + /* Device has master upper dev */ + if (netdev_master_upper_dev_get(dev)) return -EBUSY; /* No bridging devices that dislike that (e.g. wireless) */ |