lkml.org 
[lkml]   [2019]   [Mar]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH AUTOSEL 4.19 14/48] net: dsa: bcm_sf2: Do not assume DSA master supports WoL
    Date
    From: Florian Fainelli <f.fainelli@gmail.com>

    [ Upstream commit c3152ec4c0691e351f35a2f63347a464b5f35151 ]

    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: 96e65d7f3f88 ("net: dsa: bcm_sf2: add support for Wake-on-LAN")
    Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
    Signed-off-by: David S. Miller <davem@davemloft.net>
    Signed-off-by: Sasha Levin <sashal@kernel.org>
    ---
    drivers/net/dsa/bcm_sf2.c | 10 ++++++----
    1 file changed, 6 insertions(+), 4 deletions(-)

    diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c
    index fc8b48adf38b..a5e2d8df013b 100644
    --- a/drivers/net/dsa/bcm_sf2.c
    +++ b/drivers/net/dsa/bcm_sf2.c
    @@ -724,10 +724,11 @@ static void bcm_sf2_sw_get_wol(struct dsa_switch *ds, int port,
    {
    struct net_device *p = ds->ports[port].cpu_dp->master;
    struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
    - struct ethtool_wolinfo pwol;
    + struct ethtool_wolinfo pwol = { };

    /* Get the parent device WoL settings */
    - p->ethtool_ops->get_wol(p, &pwol);
    + if (p->ethtool_ops->get_wol)
    + p->ethtool_ops->get_wol(p, &pwol);

    /* Advertise the parent device supported settings */
    wol->supported = pwol.supported;
    @@ -748,9 +749,10 @@ static int bcm_sf2_sw_set_wol(struct dsa_switch *ds, int port,
    struct net_device *p = ds->ports[port].cpu_dp->master;
    struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds);
    s8 cpu_port = ds->ports[port].cpu_dp->index;
    - struct ethtool_wolinfo pwol;
    + struct ethtool_wolinfo pwol = { };

    - p->ethtool_ops->get_wol(p, &pwol);
    + if (p->ethtool_ops->get_wol)
    + p->ethtool_ops->get_wol(p, &pwol);
    if (wol->wolopts & ~pwol.supported)
    return -EINVAL;

    --
    2.19.1
    \
     
     \ /
      Last update: 2019-03-13 20:29    [W:3.249 / U:0.076 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site