* [PATCH] ALSA: us122l: drop redundant interface references
@ 2026-03-05 11:18 Johan Hovold
2026-03-05 13:04 ` Takashi Iwai
0 siblings, 1 reply; 2+ messages in thread
From: Johan Hovold @ 2026-03-05 11:18 UTC (permalink / raw)
To: Jaroslav Kysela, Takashi Iwai; +Cc: linux-sound, linux-kernel, Johan Hovold
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>
---
sound/usb/usx2y/us122l.c | 12 ++----------
1 file changed, 2 insertions(+), 10 deletions(-)
diff --git a/sound/usb/usx2y/us122l.c b/sound/usb/usx2y/us122l.c
index 011ea96e9779..f00b53346abd 100644
--- a/sound/usb/usx2y/us122l.c
+++ b/sound/usb/usx2y/us122l.c
@@ -520,8 +520,6 @@ static int us122l_usb_probe(struct usb_interface *intf,
return err;
}
- usb_get_intf(usb_ifnum_to_if(device, 0));
- usb_get_dev(device);
*cardp = card;
return 0;
}
@@ -542,11 +540,9 @@ static int snd_us122l_probe(struct usb_interface *intf,
if (intf->cur_altsetting->desc.bInterfaceNumber != 1)
return 0;
- err = us122l_usb_probe(usb_get_intf(intf), id, &card);
- if (err < 0) {
- usb_put_intf(intf);
+ err = us122l_usb_probe(intf, id, &card);
+ if (err < 0)
return err;
- }
usb_set_intfdata(intf, card);
return 0;
@@ -574,10 +570,6 @@ static void snd_us122l_disconnect(struct usb_interface *intf)
snd_usbmidi_disconnect(p);
}
- usb_put_intf(usb_ifnum_to_if(us122l->dev, 0));
- usb_put_intf(usb_ifnum_to_if(us122l->dev, 1));
- usb_put_dev(us122l->dev);
-
snd_card_free_when_closed(card);
}
--
2.52.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ALSA: us122l: drop redundant interface references
2026-03-05 11:18 [PATCH] ALSA: us122l: drop redundant interface references Johan Hovold
@ 2026-03-05 13:04 ` Takashi Iwai
0 siblings, 0 replies; 2+ messages in thread
From: Takashi Iwai @ 2026-03-05 13:04 UTC (permalink / raw)
To: Johan Hovold; +Cc: Jaroslav Kysela, Takashi Iwai, linux-sound, linux-kernel
On Thu, 05 Mar 2026 12:18:10 +0100,
Johan Hovold wrote:
>
> 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>
Thanks, applied now.
Takashi
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-05 13:04 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-05 11:18 [PATCH] ALSA: us122l: drop redundant interface references Johan Hovold
2026-03-05 13:04 ` Takashi Iwai
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox