Skip to content

Commit 224a0d2

Browse files
jhovoldkuba-moo
authored andcommitted
net: mctp: fix device leak on probe failure
Driver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect. This driver takes a reference to the USB device during probe but does not to release it on probe failures. Drop the redundant device reference to fix the leak, reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of further memory leaks. Fixes: 0791c03 ("net: mctp: Add MCTP USB transport driver") Cc: [email protected] # 6.15 Signed-off-by: Johan Hovold <[email protected]> Acked-by: Jeremy Kerr <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 0e16181 commit 224a0d2

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

drivers/net/mctp/mctp-usb.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ static int mctp_usb_probe(struct usb_interface *intf,
329329
SET_NETDEV_DEV(netdev, &intf->dev);
330330
dev = netdev_priv(netdev);
331331
dev->netdev = netdev;
332-
dev->usbdev = usb_get_dev(interface_to_usbdev(intf));
332+
dev->usbdev = interface_to_usbdev(intf);
333333
dev->intf = intf;
334334
usb_set_intfdata(intf, dev);
335335

@@ -365,7 +365,6 @@ static void mctp_usb_disconnect(struct usb_interface *intf)
365365
mctp_unregister_netdev(dev->netdev);
366366
usb_free_urb(dev->tx_urb);
367367
usb_free_urb(dev->rx_urb);
368-
usb_put_dev(dev->usbdev);
369368
free_netdev(dev->netdev);
370369
}
371370

0 commit comments

Comments
 (0)