]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
net: phy: realtek: Check the index value in led_hw_control_get
authorHui Wang <hui.wang@canonical.com>
Fri, 27 Sep 2024 11:46:10 +0000 (19:46 +0800)
committerJakub Kicinski <kuba@kernel.org>
Thu, 3 Oct 2024 00:24:56 +0000 (17:24 -0700)
Just like rtl8211f_led_hw_is_supported() and
rtl8211f_led_hw_control_set(), the rtl8211f_led_hw_control_get() also
needs to check the index value, otherwise the caller is likely to get
an incorrect rules.

Fixes: 17784801d888 ("net: phy: realtek: Add support for PHY LEDs on RTL8211F")
Signed-off-by: Hui Wang <hui.wang@canonical.com>
Reviewed-by: Marek Vasut <marex@denx.de>
Link: https://patch.msgid.link/20240927114610.1278935-1-hui.wang@canonical.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/phy/realtek.c

index 25e5bfbb6f89b8176b0a38c30562462c18cc3f2a..c15d2f66ef0dc2638706f6060a47e28d2d57f518 100644 (file)
@@ -527,6 +527,9 @@ static int rtl8211f_led_hw_control_get(struct phy_device *phydev, u8 index,
 {
        int val;
 
+       if (index >= RTL8211F_LED_COUNT)
+               return -EINVAL;
+
        val = phy_read_paged(phydev, 0xd04, RTL8211F_LEDCR);
        if (val < 0)
                return val;