aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/broadcom/bcmsysport.c
diff options
context:
space:
mode:
authorFlorian Fainelli <f.fainelli@gmail.com>2017-10-25 18:01:05 -0700
committerDavid S. Miller <davem@davemloft.net>2017-10-27 22:12:35 +0900
commitc0c21458d7d242adf9c3a3e2f3f95392164325ae (patch)
tree910cf300dd6a107a7f71629949e30cc8326d99e4 /drivers/net/ethernet/broadcom/bcmsysport.c
parentnet: dsa: Simplify dsa_slave_phy_setup() (diff)
downloadlinux-dev-c0c21458d7d242adf9c3a3e2f3f95392164325ae.tar.xz
linux-dev-c0c21458d7d242adf9c3a3e2f3f95392164325ae.zip
net: systemport: Check DSA notifier master against ourself
Check that the master network device that is signaled through the DSA notifier is actually going to be ourself, otherwise, we could just be de-referencing garbage from other drivers. Fixes: 84ff33eeb23d ("net: systemport: Establish DSA network device queue mapping") Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/broadcom/bcmsysport.c')
-rw-r--r--drivers/net/ethernet/broadcom/bcmsysport.c33
1 files changed, 18 insertions, 15 deletions
diff --git a/drivers/net/ethernet/broadcom/bcmsysport.c b/drivers/net/ethernet/broadcom/bcmsysport.c
index 1d9d5f986e14..dcee843d05d7 100644
--- a/drivers/net/ethernet/broadcom/bcmsysport.c
+++ b/drivers/net/ethernet/broadcom/bcmsysport.c
@@ -2046,6 +2046,21 @@ static u16 bcm_sysport_select_queue(struct net_device *dev, struct sk_buff *skb,
return tx_ring->index;
}
+static const struct net_device_ops bcm_sysport_netdev_ops = {
+ .ndo_start_xmit = bcm_sysport_xmit,
+ .ndo_tx_timeout = bcm_sysport_tx_timeout,
+ .ndo_open = bcm_sysport_open,
+ .ndo_stop = bcm_sysport_stop,
+ .ndo_set_features = bcm_sysport_set_features,
+ .ndo_set_rx_mode = bcm_sysport_set_rx_mode,
+ .ndo_set_mac_address = bcm_sysport_change_mac,
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ .ndo_poll_controller = bcm_sysport_poll_controller,
+#endif
+ .ndo_get_stats64 = bcm_sysport_get_stats64,
+ .ndo_select_queue = bcm_sysport_select_queue,
+};
+
static int bcm_sysport_map_queues(struct net_device *dev,
struct dsa_notifier_register_info *info)
{
@@ -2061,6 +2076,9 @@ static int bcm_sysport_map_queues(struct net_device *dev,
if (info->switch_number)
return 0;
+ if (dev->netdev_ops != &bcm_sysport_netdev_ops)
+ return 0;
+
port = info->port_number;
slave_dev = info->info.dev;
@@ -2112,21 +2130,6 @@ static int bcm_sysport_dsa_notifier(struct notifier_block *unused,
return notifier_from_errno(bcm_sysport_map_queues(info->master, info));
}
-static const struct net_device_ops bcm_sysport_netdev_ops = {
- .ndo_start_xmit = bcm_sysport_xmit,
- .ndo_tx_timeout = bcm_sysport_tx_timeout,
- .ndo_open = bcm_sysport_open,
- .ndo_stop = bcm_sysport_stop,
- .ndo_set_features = bcm_sysport_set_features,
- .ndo_set_rx_mode = bcm_sysport_set_rx_mode,
- .ndo_set_mac_address = bcm_sysport_change_mac,
-#ifdef CONFIG_NET_POLL_CONTROLLER
- .ndo_poll_controller = bcm_sysport_poll_controller,
-#endif
- .ndo_get_stats64 = bcm_sysport_get_stats64,
- .ndo_select_queue = bcm_sysport_select_queue,
-};
-
#define REV_FMT "v%2x.%02x"
static const struct bcm_sysport_hw_params bcm_sysport_params[] = {