Skip to content
Commit ce93fdb5 authored by Clément Léger's avatar Clément Léger Committed by David S. Miller
Browse files

net: phylink: move phy_device_free() to correctly release phy device

After calling fwnode_phy_find_device(), the phy device refcount is
incremented. Then, when the phy device is attached to a netdev with
phy_attach_direct(), the refcount is also incremented but only
decremented in the caller if phy_attach_direct() fails. Move
phy_device_free() before the "if" to always release it correctly.
Indeed, either phy_attach_direct() failed and we don't want to keep a
reference to the phydev or it succeeded and a reference has been taken
internally.

Fixes: 25396f68

 ("net: phylink: introduce phylink_fwnode_phy_connect()")
Signed-off-by: default avatarClément Léger <clement.leger@bootlin.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent edb9b8f3
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment