]>
Commit | Line | Data |
---|---|---|
36e3f504 SL |
1 | From e1d1ab0dbd532a1df39531500ac67558bc9cbb21 Mon Sep 17 00:00:00 2001 |
2 | From: Florian Fainelli <f.fainelli@gmail.com> | |
3 | Date: Fri, 15 Feb 2019 12:16:52 -0800 | |
4 | Subject: net: dsa: bcm_sf2: Do not assume DSA master supports WoL | |
5 | ||
6 | [ Upstream commit c3152ec4c0691e351f35a2f63347a464b5f35151 ] | |
7 | ||
8 | We assume in the bcm_sf2 driver that the DSA master network device | |
9 | supports ethtool_ops::{get,set}_wol operations, which is not a given. | |
10 | Avoid de-referencing potentially non-existent function pointers and | |
11 | check them as we should. | |
12 | ||
13 | Fixes: 96e65d7f3f88 ("net: dsa: bcm_sf2: add support for Wake-on-LAN") | |
14 | Signed-off-by: Florian Fainelli <f.fainelli@gmail.com> | |
15 | Signed-off-by: David S. Miller <davem@davemloft.net> | |
16 | Signed-off-by: Sasha Levin <sashal@kernel.org> | |
17 | --- | |
18 | drivers/net/dsa/bcm_sf2.c | 10 ++++++---- | |
19 | 1 file changed, 6 insertions(+), 4 deletions(-) | |
20 | ||
21 | diff --git a/drivers/net/dsa/bcm_sf2.c b/drivers/net/dsa/bcm_sf2.c | |
22 | index bb26a193361e..2fa2caf7a746 100644 | |
23 | --- a/drivers/net/dsa/bcm_sf2.c | |
24 | +++ b/drivers/net/dsa/bcm_sf2.c | |
25 | @@ -724,10 +724,11 @@ static void bcm_sf2_sw_get_wol(struct dsa_switch *ds, int port, | |
26 | { | |
27 | struct net_device *p = ds->ports[port].cpu_dp->master; | |
28 | struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds); | |
29 | - struct ethtool_wolinfo pwol; | |
30 | + struct ethtool_wolinfo pwol = { }; | |
31 | ||
32 | /* Get the parent device WoL settings */ | |
33 | - p->ethtool_ops->get_wol(p, &pwol); | |
34 | + if (p->ethtool_ops->get_wol) | |
35 | + p->ethtool_ops->get_wol(p, &pwol); | |
36 | ||
37 | /* Advertise the parent device supported settings */ | |
38 | wol->supported = pwol.supported; | |
39 | @@ -748,9 +749,10 @@ static int bcm_sf2_sw_set_wol(struct dsa_switch *ds, int port, | |
40 | struct net_device *p = ds->ports[port].cpu_dp->master; | |
41 | struct bcm_sf2_priv *priv = bcm_sf2_to_priv(ds); | |
42 | s8 cpu_port = ds->ports[port].cpu_dp->index; | |
43 | - struct ethtool_wolinfo pwol; | |
44 | + struct ethtool_wolinfo pwol = { }; | |
45 | ||
46 | - p->ethtool_ops->get_wol(p, &pwol); | |
47 | + if (p->ethtool_ops->get_wol) | |
48 | + p->ethtool_ops->get_wol(p, &pwol); | |
49 | if (wol->wolopts & ~pwol.supported) | |
50 | return -EINVAL; | |
51 | ||
52 | -- | |
53 | 2.19.1 | |
54 |