Skip to content

Commit 27c1eaa

Browse files
tititiou36davem330
authored andcommitted
net: mdio: mvusb: Fix an error handling path in mvusb_mdio_probe()
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>
1 parent 424f841 commit 27c1eaa

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

drivers/net/mdio/mdio-mvusb.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ static int mvusb_mdio_probe(struct usb_interface *interface,
6767
struct device *dev = &interface->dev;
6868
struct mvusb_mdio *mvusb;
6969
struct mii_bus *mdio;
70+
int ret;
7071

7172
mdio = devm_mdiobus_alloc_size(dev, sizeof(*mvusb));
7273
if (!mdio)
@@ -87,7 +88,15 @@ static int mvusb_mdio_probe(struct usb_interface *interface,
8788
mdio->write = mvusb_mdio_write;
8889

8990
usb_set_intfdata(interface, mvusb);
90-
return of_mdiobus_register(mdio, dev->of_node);
91+
ret = of_mdiobus_register(mdio, dev->of_node);
92+
if (ret)
93+
goto put_dev;
94+
95+
return 0;
96+
97+
put_dev:
98+
usb_put_dev(mvusb->udev);
99+
return ret;
91100
}
92101

93102
static void mvusb_mdio_disconnect(struct usb_interface *interface)

0 commit comments

Comments
 (0)