a6f8b6d1c51a424ee41e0851af6865f34455eaf4
[openwrt/staging/wigyori.git] /
1 From c283782fc5d60c4d8169137c6f955aa3553d3b3d Mon Sep 17 00:00:00 2001
2 From: Hui Wang <hui.wang@canonical.com>
3 Date: Fri, 27 Sep 2024 19:46:10 +0800
4 Subject: [PATCH] net: phy: realtek: Check the index value in
5 led_hw_control_get
6
7 Just like rtl8211f_led_hw_is_supported() and
8 rtl8211f_led_hw_control_set(), the rtl8211f_led_hw_control_get() also
9 needs to check the index value, otherwise the caller is likely to get
10 an incorrect rules.
11
12 Fixes: 17784801d888 ("net: phy: realtek: Add support for PHY LEDs on RTL8211F")
13 Signed-off-by: Hui Wang <hui.wang@canonical.com>
14 Reviewed-by: Marek Vasut <marex@denx.de>
15 Link: https://patch.msgid.link/20240927114610.1278935-1-hui.wang@canonical.com
16 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
17 ---
18 drivers/net/phy/realtek.c | 3 +++
19 1 file changed, 3 insertions(+)
20
21 --- a/drivers/net/phy/realtek.c
22 +++ b/drivers/net/phy/realtek.c
23 @@ -527,6 +527,9 @@ static int rtl8211f_led_hw_control_get(s
24 {
25 int val;
26
27 + if (index >= RTL8211F_LED_COUNT)
28 + return -EINVAL;
29 +
30 val = phy_read_paged(phydev, 0xd04, RTL8211F_LEDCR);
31 if (val < 0)
32 return val;