Skip to content

Commit 3d543d9

Browse files
jhovoldtiwai
authored andcommitted
ALSA: us122l: drop redundant interface references
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. Similarly, USB core holds a reference to all interfaces in the active configuration so there is no need for a driver to take a reference to a sibling interface only to release it at disconnect either. Drop the redundant references to reduce cargo culting, make it easier to spot drivers where extra references are needed, and reduce the risk of memory leaks when drivers fail to release them. Signed-off-by: Johan Hovold <johan@kernel.org> Link: https://patch.msgid.link/20260305111810.18688-1-johan@kernel.org Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent 7ae0d8f commit 3d543d9

1 file changed

Lines changed: 2 additions & 10 deletions

File tree

sound/usb/usx2y/us122l.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -520,8 +520,6 @@ static int us122l_usb_probe(struct usb_interface *intf,
520520
return err;
521521
}
522522

523-
usb_get_intf(usb_ifnum_to_if(device, 0));
524-
usb_get_dev(device);
525523
*cardp = card;
526524
return 0;
527525
}
@@ -542,11 +540,9 @@ static int snd_us122l_probe(struct usb_interface *intf,
542540
if (intf->cur_altsetting->desc.bInterfaceNumber != 1)
543541
return 0;
544542

545-
err = us122l_usb_probe(usb_get_intf(intf), id, &card);
546-
if (err < 0) {
547-
usb_put_intf(intf);
543+
err = us122l_usb_probe(intf, id, &card);
544+
if (err < 0)
548545
return err;
549-
}
550546

551547
usb_set_intfdata(intf, card);
552548
return 0;
@@ -574,10 +570,6 @@ static void snd_us122l_disconnect(struct usb_interface *intf)
574570
snd_usbmidi_disconnect(p);
575571
}
576572

577-
usb_put_intf(usb_ifnum_to_if(us122l->dev, 0));
578-
usb_put_intf(usb_ifnum_to_if(us122l->dev, 1));
579-
usb_put_dev(us122l->dev);
580-
581573
snd_card_free_when_closed(card);
582574
}
583575

0 commit comments

Comments
 (0)