Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 04e37d92fbed ("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>

authored by

Christophe JAILLET and committed by
David S. Miller
27c1eaa0 424f8416

+10 -1
+10 -1
drivers/net/mdio/mdio-mvusb.c
··· 67 67 struct device *dev = &interface->dev; 68 68 struct mvusb_mdio *mvusb; 69 69 struct mii_bus *mdio; 70 + int ret; 70 71 71 72 mdio = devm_mdiobus_alloc_size(dev, sizeof(*mvusb)); 72 73 if (!mdio) ··· 88 87 mdio->write = mvusb_mdio_write; 89 88 90 89 usb_set_intfdata(interface, mvusb); 91 - return of_mdiobus_register(mdio, dev->of_node); 90 + ret = of_mdiobus_register(mdio, dev->of_node); 91 + if (ret) 92 + goto put_dev; 93 + 94 + return 0; 95 + 96 + put_dev: 97 + usb_put_dev(mvusb->udev); 98 + return ret; 92 99 } 93 100 94 101 static void mvusb_mdio_disconnect(struct usb_interface *interface)