Skip to content

Commit

Permalink
net: mdio: mvusb: Fix an error handling path in mvusb_mdio_probe()
Browse files Browse the repository at this point in the history
[ Upstream commit 27c1eaa ]

Should of_mdiobus_register() fail, a previous usb_get_dev() call should be
undone as in the .disconnect function.

Fixes: 04e37d9 ("net: phy: add marvell usb to mdio controller")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
tititiou36 authored and gregkh committed May 24, 2023
1 parent 3e785c8 commit 27c6b57
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion drivers/net/mdio/mdio-mvusb.c
Expand Up @@ -73,6 +73,7 @@ static int mvusb_mdio_probe(struct usb_interface *interface,
struct device *dev = &interface->dev;
struct mvusb_mdio *mvusb;
struct mii_bus *mdio;
int ret;

mdio = devm_mdiobus_alloc_size(dev, sizeof(*mvusb));
if (!mdio)
Expand All @@ -93,7 +94,15 @@ static int mvusb_mdio_probe(struct usb_interface *interface,
mdio->write = mvusb_mdio_write;

usb_set_intfdata(interface, mvusb);
return of_mdiobus_register(mdio, dev->of_node);
ret = of_mdiobus_register(mdio, dev->of_node);
if (ret)
goto put_dev;

return 0;

put_dev:
usb_put_dev(mvusb->udev);
return ret;
}

static void mvusb_mdio_disconnect(struct usb_interface *interface)
Expand Down

0 comments on commit 27c6b57

Please sign in to comment.