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

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>

authored by

Johan Hovold and committed by
Takashi Iwai
3d543d95 7ae0d8f1

+2 -10
+2 -10
sound/usb/usx2y/us122l.c
··· 520 return err; 521 } 522 523 - usb_get_intf(usb_ifnum_to_if(device, 0)); 524 - usb_get_dev(device); 525 *cardp = card; 526 return 0; 527 } ··· 540 if (intf->cur_altsetting->desc.bInterfaceNumber != 1) 541 return 0; 542 543 - err = us122l_usb_probe(usb_get_intf(intf), id, &card); 544 - if (err < 0) { 545 - usb_put_intf(intf); 546 return err; 547 - } 548 549 usb_set_intfdata(intf, card); 550 return 0; ··· 569 list_for_each(p, &us122l->midi_list) { 570 snd_usbmidi_disconnect(p); 571 } 572 - 573 - usb_put_intf(usb_ifnum_to_if(us122l->dev, 0)); 574 - usb_put_intf(usb_ifnum_to_if(us122l->dev, 1)); 575 - usb_put_dev(us122l->dev); 576 577 snd_card_free_when_closed(card); 578 }
··· 520 return err; 521 } 522 523 *cardp = card; 524 return 0; 525 } ··· 542 if (intf->cur_altsetting->desc.bInterfaceNumber != 1) 543 return 0; 544 545 + err = us122l_usb_probe(intf, id, &card); 546 + if (err < 0) 547 return err; 548 549 usb_set_intfdata(intf, card); 550 return 0; ··· 573 list_for_each(p, &us122l->midi_list) { 574 snd_usbmidi_disconnect(p); 575 } 576 577 snd_card_free_when_closed(card); 578 }