Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ab28ff11 authored by Danny Segal's avatar Danny Segal Committed by Matt Wagantall
Browse files

usb: gadget: audio: Resolve memory leaks in audio playback and capture



When the USB host initiates USB audio playback of capture, set_alt(1)
command is sent to the device. In response, the USB driver allocates a new
set of USB requests for handling the audio data. This is done every time
when a set_alt(1) command is sent by the USB host, and the requests never
get freed after then. The fix resolves this issue by ignoring set alt
commands if the interface is already set to this alt interface.

Change-Id: I4ac0acf2ac714bc132cfc0f99c2d04174e31b99b
CRs-fixed: 732934
Signed-off-by: default avatarDanny Segal <dsegal@codeaurora.org>
parent eae846ce
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -960,6 +960,13 @@ static int f_audio_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
	audio_playback_buf_size = opts->audio_playback_buf_size;

	if (intf == ac_header_desc.baInterfaceNr[0]) {
		if (audio->alt_intf[0] == alt) {
			pr_debug("Alt interface is already set to %d. Do nothing.\n",
				alt);

			return 0;
		}

		if (alt == 1) {
			err = usb_ep_enable(in_ep);
			if (err) {
@@ -1007,6 +1014,13 @@ static int f_audio_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
		}
		audio->alt_intf[0] = alt;
	} else if (intf == ac_header_desc.baInterfaceNr[1]) {
		if (audio->alt_intf[1] == alt) {
			pr_debug("Alt interface is already set to %d. Do nothing.\n",
				alt);

			return 0;
		}

		if (alt == 1) {
			err = usb_ep_enable(out_ep);
			if (err) {