diff mbox series

net: phy: realtek: Check the index value in led_hw_control_get

Message ID 20240927114610.1278935-1-hui.wang@canonical.com (mailing list archive)
State Accepted
Commit c283782fc5d60c4d8169137c6f955aa3553d3b3d
Delegated to: Netdev Maintainers
Headers show
Series net: phy: realtek: Check the index value in led_hw_control_get | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 9 this patch: 9
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 9 this patch: 9
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn fail Errors and warnings before: 12 this patch: 12
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 9 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Hui Wang Sept. 27, 2024, 11:46 a.m. UTC
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>
---
 drivers/net/phy/realtek.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Marek Vasut Sept. 27, 2024, 12:12 p.m. UTC | #1
On 9/27/24 1:46 PM, Hui Wang wrote:
> 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>

Thanks !
patchwork-bot+netdevbpf@kernel.org Oct. 3, 2024, 12:40 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 27 Sep 2024 19:46:10 +0800 you wrote:
> 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>
> 
> [...]

Here is the summary with links:
  - net: phy: realtek: Check the index value in led_hw_control_get
    https://git.kernel.org/netdev/net/c/c283782fc5d6

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
index 25e5bfbb6f89..c15d2f66ef0d 100644
--- a/drivers/net/phy/realtek.c
+++ b/drivers/net/phy/realtek.c
@@ -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;