5f3b119a89e0204dd74a71398c7483fd67cbb61a
[openwrt/staging/xback.git] /
1 From a9b24b3583ae1da7dbda031f141264f2da260219 Mon Sep 17 00:00:00 2001
2 From: Daniel Braunwarth <daniel.braunwarth@kuka.com>
3 Date: Tue, 24 Jun 2025 16:17:33 +0200
4 Subject: [PATCH] net: phy: realtek: add error handling to rtl8211f_get_wol
5
6 We should check if the WOL settings was successfully read from the PHY.
7
8 In case this fails we cannot just use the error code and proceed.
9
10 Signed-off-by: Daniel Braunwarth <daniel.braunwarth@kuka.com>
11 Reported-by: Jon Hunter <jonathanh@nvidia.com>
12 Closes: https://lore.kernel.org/baaa083b-9a69-460f-ab35-2a7cb3246ffd@nvidia.com
13 Reviewed-by: Andrew Lunn <andrew@lunn.ch>
14 Link: https://patch.msgid.link/20250624-realtek_fixes-v1-1-02a0b7c369bc@kuka.com
15 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
16 ---
17 drivers/net/phy/realtek/realtek_main.c | 10 ++++++++--
18 1 file changed, 8 insertions(+), 2 deletions(-)
19
20 --- a/drivers/net/phy/realtek/realtek_main.c
21 +++ b/drivers/net/phy/realtek/realtek_main.c
22 @@ -436,9 +436,15 @@ static irqreturn_t rtl8211f_handle_inter
23
24 static void rtl8211f_get_wol(struct phy_device *dev, struct ethtool_wolinfo *wol)
25 {
26 + int wol_events;
27 +
28 wol->supported = WAKE_MAGIC;
29 - if (phy_read_paged(dev, RTL8211F_WOL_SETTINGS_PAGE, RTL8211F_WOL_SETTINGS_EVENTS)
30 - & RTL8211F_WOL_EVENT_MAGIC)
31 +
32 + wol_events = phy_read_paged(dev, RTL8211F_WOL_SETTINGS_PAGE, RTL8211F_WOL_SETTINGS_EVENTS);
33 + if (wol_events < 0)
34 + return;
35 +
36 + if (wol_events & RTL8211F_WOL_EVENT_MAGIC)
37 wol->wolopts = WAKE_MAGIC;
38 }
39