Re: [PATCH net] net: phylink: put link_gpio if phylink_create fails

From: Andrew Lunn

Date: Sun Jul 26 2026 - 12:50:57 EST


On Sun, Jul 26, 2026 at 05:08:05PM +0200, Christian Marangi wrote:
> In phylink_create() if phylink_register_sfp() returns an error, link_gpio
> obtained by phylink_parse_fixedlink() is never released. While this is a
> very unlikely scenario, it's worth to fix/handle this.
>
> This was present from the very first implementation of phylink but got
> relevant only with the introduction of ce0aa27ff3f6 ("sfp: add sfp-bus to
> bridge between network devices and sfp cages") where additional function
> were added after phylink_parse_fixedlink() making the release of link_gpio
> needed if such additional function errored out.
>
> While at it, restructure the exit condition of phylink_create() with the
> goto pattern to reduce code duplication on handling error conditions.
>
> Fixes: ce0aa27ff3f6 ("sfp: add sfp-bus to bridge between network devices and sfp cages")
> Signed-off-by: Christian Marangi <ansuelsmth@xxxxxxxxx>

Reviewed-by: Andrew Lunn <andrew@xxxxxxx>

Andrew