Skip to contentSkip to conversation

rtl8365mb: initialize ret in phy_ocp_read and return ret in phy_ocp_write

PATCH In review Mietek N 2 participants 3 messages Nov 16, 2025 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Mietek N

author
#1 lore raw

PATCH 1/1 rtl8365mb: initialize ret in phy_ocp_read and return ret in phy_ocp_write

This patch fixes two issues in the RTL8365MB driver:

 - Initialize the 'ret' variable in rtl8365mb_phy_ocp_read() to 0 to avoid using an uninitialized automatic variable on some execution paths.
 - Propagate the return value from rtl8365mb_phy_ocp_write() by returning 'ret' instead of always returning 0, so write failures are not silently ignored.

No other changes are made and the PHY OCP helper functions themselves remain functionally identical except for the corrected return behaviour.

---
 drivers/net/dsa/realtek/rtl8365mb.c | 6 +++---

 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/dsa/realtek/rtl8365mb.c    2025-11-16 14:02:57.000000000 +0100 renamed from drivers/net/dsa/realtek/rtl8365mb.c    2025-10-12 22:42:36.000000000 +0200 +0 -0
diff -ruN a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/rtl8365mb.c
@@ -690,7 +690,7 @@

                   u32 ocp_addr, u16 *data)
 {
     u32 val;
-    int ret;
+    int ret = 0;

     rtl83xx_lock(priv);

@@ -769,7 +769,7 @@
 out:
     rtl83xx_unlock(priv);

-    return 0;
+    return ret;
 }

 static int rtl8365mb_phy_read(struct realtek_priv *priv, int phy, int regnum) --
2.39.3

maintainer
#2 lore raw
Quoted 26 lines · Mietek N

This patch fixes two issues in the RTL8365MB driver:

 - Initialize the 'ret' variable in rtl8365mb_phy_ocp_read() to 0 to avoid using an uninitialized automatic variable on some execution paths.
 - Propagate the return value from rtl8365mb_phy_ocp_write() by returning 'ret' instead of always returning 0, so write failures are not silently ignored.

No other changes are made and the PHY OCP helper functions themselves remain functionally identical except for the corrected return behaviour.

---
 drivers/net/dsa/realtek/rtl8365mb.c | 6 +++---

 1 file changed, 3 insertions(+), 3 deletions(-)

diff -ruN a/drivers/net/dsa/realtek/rtl8365mb.c b/drivers/net/dsa/realtek/rtl8365mb.c

drivers/net/dsa/realtek/rtl8365mb.c    2025-11-16 14:02:57.000000000 +0100 renamed from drivers/net/dsa/realtek/rtl8365mb.c    2025-10-12 22:42:36.000000000 +0200 +1 -1
@@ -690,7 +690,7 @@
                    u32 ocp_addr, u16 *data)
  {
      u32 val;
-    int ret;
+    int ret = 0;
Quoted 3 lines


     rtl83xx_lock(priv);

You diff is a bit odd, normally the name of the function is in the header. But the commit message says this is rtl8365mb_phy_ocp_read()

static int rtl8365mb_phy_ocp_read(struct realtek_priv *priv, int phy,

				  u32 ocp_addr, u16 *data)
{
	u32 val;
	int ret;

	rtl83xx_lock(priv);

	ret = rtl8365mb_phy_poll_busy(priv);
	if (ret)
		goto out;

ret has been assigned a value, before the goto. So all execution paths have a valid ret value.

Am i missing something?

Andrew

---
pw-bot: cr

author
#3 lore raw

You're rightTrue. I generated the patch again, this topic can be closed