Commit c3152ec4 authored by Florian Fainelli's avatar Florian Fainelli Committed by David S. Miller

net: dsa: bcm_sf2: Do not assume DSA master supports WoL

We assume in the bcm_sf2 driver that the DSA master network device
supports ethtool_ops::{get,set}_wol operations, which is not a given.
Avoid de-referencing potentially non-existent function pointers and
check them as we should.

Fixes: 96e65d7f ("net: dsa: bcm_sf2: add support for Wake-on-LAN")
Signed-off-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a40061ea
...@@ -726,9 +726,10 @@ static void bcm_sf2_sw_get_wol(struct dsa_switch *ds, int port, ...@@ -726,9 +726,10 @@ static void bcm_sf2_sw_get_wol(struct dsa_switch *ds, int port,
{ {
struct net_device *p = ds->ports[port].cpu_dp->master; struct net_device *p = ds->ports[port].cpu_dp->master;
struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds); struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
struct ethtool_wolinfo pwol; struct ethtool_wolinfo pwol = { };
/* Get the parent device WoL settings */ /* Get the parent device WoL settings */
if (p->ethtool_ops->get_wol)
p->ethtool_ops->get_wol(p, &pwol); p->ethtool_ops->get_wol(p, &pwol);
/* Advertise the parent device supported settings */ /* Advertise the parent device supported settings */
...@@ -750,8 +751,9 @@ static int bcm_sf2_sw_set_wol(struct dsa_switch *ds, int port, ...@@ -750,8 +751,9 @@ static int bcm_sf2_sw_set_wol(struct dsa_switch *ds, int port,
struct net_device *p = ds->ports[port].cpu_dp->master; struct net_device *p = ds->ports[port].cpu_dp->master;
struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds); struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
s8 cpu_port = ds->ports[port].cpu_dp->index; s8 cpu_port = ds->ports[port].cpu_dp->index;
struct ethtool_wolinfo pwol; struct ethtool_wolinfo pwol = { };
if (p->ethtool_ops->get_wol)
p->ethtool_ops->get_wol(p, &pwol); p->ethtool_ops->get_wol(p, &pwol);
if (wol->wolopts & ~pwol.supported) if (wol->wolopts & ~pwol.supported)
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment