]> git.ipfire.org Git - thirdparty/openwrt.git/commitdiff
realtek: mdio: avoid access to uninitialized variable
authorMarkus Stockhausen <markus.stockhausen@gmx.de>
Sun, 3 May 2026 16:17:58 +0000 (18:17 +0200)
committerRobert Marko <robimarko@gmail.com>
Tue, 5 May 2026 11:12:17 +0000 (13:12 +0200)
The read functions might fail and thus "val" might be uninitialized.
The debug function will output the undefined state. Set the value
to zero to be consistent.

Signed-off-by: Markus Stockhausen <markus.stockhausen@gmx.de>
Link: https://github.com/openwrt/openwrt/pull/23204
Signed-off-by: Robert Marko <robimarko@gmail.com>
target/linux/realtek/files-6.18/drivers/net/mdio/mdio-realtek-otto.c

index 0e10720b491b68d0f66a8beaf51c88d7b2b82c8a..dbad94845527acd84a84a1f0ba91a2ca9852b5e3 100644 (file)
@@ -513,7 +513,7 @@ static int rtmdio_931x_write_c45(struct mii_bus *bus, u32 pn, u32 devnum, u32 re
 static int rtmdio_read_c45(struct mii_bus *bus, int phy, int devnum, int regnum)
 {
        struct rtmdio_ctrl *ctrl = rtmdio_ctrl_from_bus(bus);
-       int ret, val, pn;
+       int ret, pn, val = 0;
 
        pn = rtmdio_phy_to_port(bus, phy);
        if (pn < 0)
@@ -530,7 +530,7 @@ static int rtmdio_read_c45(struct mii_bus *bus, int phy, int devnum, int regnum)
 static int rtmdio_read_c22(struct mii_bus *bus, int phy, int regnum)
 {
        struct rtmdio_ctrl *ctrl = rtmdio_ctrl_from_bus(bus);
-       int ret, val, pn;
+       int ret, pn, val = 0;
 
        pn = rtmdio_phy_to_port(bus, phy);
        if (pn < 0)