net: ethernet: stmmac: ensure balanced gpiod_put when reset_gpio is non-existent

[    2.911481] ------------[ cut here ]------------
[    2.911491] WARNING: CPU: 2 PID: 1 at drivers/gpio/gpiolib-devres.c:327 devm_gpiod_put+0x38/0x44
[    2.911523] Modules linked in:
[    2.911538] CPU: 2 PID: 1 Comm: swapper/0 Not tainted 6.1.118 #4
[    2.911555] Hardware name: Rockchip RV1126B EVB2 V10 Board (DT)
[    2.911566] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[    2.911583] pc : devm_gpiod_put+0x38/0x44
[    2.911601] lr : devm_gpiod_put+0x2c/0x44
[    2.911617] sp : ffffffc00a7cb8e0
[    2.911626] x29: ffffffc00a7cb8e0 x28: 0000000000000000 x27: ffffffc009b300c8
[    2.911653] x26: 0000000000000020 x25: ffffff80036ee4a0 x24: ffffff807fb95230
[    2.911679] x23: ffffff80036ee4a0 x22: 0000000000000000 x21: 0000000000000200
[    2.911704] x20: 0000000000000000 x19: ffffff8003700880 x18: 0000000000000030
[    2.911730] x17: 00000000adb2a87f x16: 000000004c06ebf7 x15: ffffffffffffffff
[    2.911757] x14: 0000000000000000 x13: 0a303d6f6970675f x12: 7465736572205d35
[    2.911782] x11: fffffffffffc3f18 x10: 00000000001104c0 x9 : ffffffc0089860b4
[    2.911808] x8 : 0101010101010101 x7 : 79616c65642d7465 x6 : 1d0f1d16acf2e5f3
[    2.911833] x5 : ffffff8003215eb8 x4 : 0000000000000000 x3 : ffffffc0089859a0
[    2.911858] x2 : ffffffc00a7cb8f8 x1 : ffffff8003215eb8 x0 : 00000000fffffffe
[    2.911884] Call trace:
[    2.911893]  devm_gpiod_put+0x38/0x44
[    2.911911]  stmmac_mdio_reset+0x11c/0x160
[    2.911930]  __mdiobus_register+0x14c/0x380
[    2.911948]  __of_mdiobus_register+0xbc/0x3c0
[    2.911969]  stmmac_mdio_register+0x140/0x334
[    2.911986]  stmmac_dvr_probe+0xf3c/0x1124
[    2.912000]  rk_gmac_probe+0x59c/0x930
[    2.912017]  platform_probe+0x6c/0xd4
[    2.912039]  really_probe+0xc4/0x3e0
[    2.912058]  __driver_probe_device+0x80/0x160
[    2.912077]  driver_probe_device+0x40/0x110
[    2.912096]  __driver_attach+0xec/0x1f0
[    2.912115]  bus_for_each_dev+0x74/0xd0
[    2.912132]  driver_attach+0x28/0x30
[    2.912150]  bus_add_driver+0x178/0x234
[    2.912168]  driver_register+0x7c/0x130
[    2.912188]  __platform_driver_register+0x2c/0x34
[    2.912210]  rk_gmac_dwmac_driver_init+0x20/0x28
[    2.912227]  do_one_initcall+0x48/0x250
[    2.912245]  kernel_init_freeable+0x298/0x300
[    2.912266]  kernel_init+0x28/0x12c
[    2.912288]  ret_from_fork+0x10/0x20

Fixes: 72834b57d9 ("ethernet: stmmac: Release reset gpio desc for mdio reset")
Change-Id: I5d0f171abf5f66d2fe5eaa6e8089e870d6d4f308
Signed-off-by: Ziyuan Xu <xzy.xu@rock-chips.com>
Signed-off-by: David Wu <david.wu@rock-chips.com>
This commit is contained in:
Ziyuan Xu
2025-03-26 16:24:18 +08:00
committed by Tao Huang
parent f13e482d26
commit c458c9f8a8

View File

@@ -356,8 +356,8 @@ int stmmac_mdio_idle(struct mii_bus *bus)
reset_gpio = devm_gpiod_get_optional(priv->device,
"snps,reset",
GPIOD_OUT_HIGH);
if (IS_ERR(reset_gpio))
return PTR_ERR(reset_gpio);
if (IS_ERR_OR_NULL(reset_gpio))
return PTR_ERR_OR_ZERO(reset_gpio);
devm_gpiod_put(priv->device, reset_gpio);
}
@@ -386,8 +386,8 @@ int stmmac_mdio_reset(struct mii_bus *bus)
reset_gpio = devm_gpiod_get_optional(priv->device,
"snps,reset",
GPIOD_OUT_LOW);
if (IS_ERR(reset_gpio))
return PTR_ERR(reset_gpio);
if (IS_ERR_OR_NULL(reset_gpio))
return PTR_ERR_OR_ZERO(reset_gpio);
device_property_read_u32_array(priv->device,
"snps,reset-delays-us",