dpll: zl3073x: fix memory leak on pin registration failure
Subsystems (4)
Ivan Vecera
maintainerPATCH v2 1/1 dpll: zl3073x: fix memory leak on pin registration failure
If zl3073x_dpll_pin_register() fails, the allocated pin is not yet added to zldpll->pins list. The error path calls zl3073x_dpll_pins_unregister() which only iterates pins on the list, so the current pin is leaked. Free the pin before jumping to the error label.
Additionally move the pin->dpll_pin = NULL assignment in zl3073x_dpll_pin_register() from err_register to the common err_pin_get path. When dpll_pin_get() fails, pin->dpll_pin holds an ERR_PTR value. Without this fix the subsequent zl3073x_dpll_pin_free() would trigger a spurious WARN because it checks pin->dpll_pin for non-NULL.
---
v2: Move pin->dpll_pin = NULL to err_pin_get path to avoid spurious
WARN when dpll_pin_get() fails with ERR_PTR.
--- drivers/dpll/zl3073x/dpll.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/dpll/zl3073x/dpll.c +4 -2
@@ -1394,8 +1394,8 @@ zl3073x_dpll_pin_register(struct zl3073x_dpll_pin *pin, u32 index) err_register:dpll_pin_put (pin->dpll_pin, &pin->tracker); - pin->dpll_pin =NULL ; err_pin_get: + pin->dpll_pin =NULL ;fwnode_handle_put (pin->fwnode); pin->fwnode =NULL ;zl3073x_pin_props_put (props);
@@ -1563,8 +1563,10 @@ zl3073x_dpll_pins_register(struct zl3073x_dpll *zldpll) } rc =zl3073x_dpll_pin_register (pin, index); -if (rc) +if (rc) { +zl3073x_dpll_pin_free (pin); goto error; + }list_add (&pin->list, &zldpll->pins); }
Signature · 1 line
2.53.0
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 6 lines · On Tue, 19 May 2026 15:22:05 +0200 you wrote:
If
zl3073x_dpll_pin_register()fails, the allocated pin is not yet added tozldpll->pinslist. The error path callszl3073x_dpll_pins_unregister()which only iterates pins on the list, so the current pin is leaked. Free the pin before jumping to the error label.
Quoted 8 lines
Additionally move the
pin->dpll_pin= NULL assignment inzl3073x_dpll_pin_register()fromerr_registerto the commonerr_pin_getpath. Whendpll_pin_get()fails,pin->dpll_pinholds anERR_PTRvalue. Without this fix the subsequentzl3073x_dpll_pin_free()would trigger a spurious WARN because it checkspin->dpll_pinfor non-NULL.[...]
Here is the summary with links:
- [net,v2] dpll: zl3073x: fix memory leak on pin registration failure
https://git.kernel.org/netdev/net/c/fa997ddef508
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html