<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/drivers/usb/gadget/function/u_audio.c, branch v6.12.80</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v6.12.80</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v6.12.80'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2024-08-12T16:49:00+00:00</updated>
<entry>
<title>Merge 6.11-rc3 into usb-next</title>
<updated>2024-08-12T16:49:00+00:00</updated>
<author>
<name>Greg Kroah-Hartman</name>
<email>gregkh@linuxfoundation.org</email>
</author>
<published>2024-08-12T16:49:00+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=38343be0bf9a7d7ef0d160da5f2db887a0e29b62'/>
<id>urn:sha1:38343be0bf9a7d7ef0d160da5f2db887a0e29b62</id>
<content type='text'>
We need the usb fixes in here as well.

Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: gadget: u_audio: Use C99 syntax for array initializers</title>
<updated>2024-08-07T10:50:55+00:00</updated>
<author>
<name>Abhishek Tamboli</name>
<email>abhishektamboli9@gmail.com</email>
</author>
<published>2024-08-01T19:02:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=260126159200c2724dab14dd332f79282ff9721a'/>
<id>urn:sha1:260126159200c2724dab14dd332f79282ff9721a</id>
<content type='text'>
Convert array initializers to C99 syntax by adding the '=' after
each designated initializer.

Fix the following smatch warnings:

drivers/usb/gadget/function/u_audio.c:1117:20:
warning: obsolete array initializer, use C99 syntax
drivers/usb/gadget/function/u_audio.c:1124:28:
warning: obsolete array initializer, use C99 syntax
drivers/usb/gadget/function/u_audio.c:1131:19:
warning: obsolete array initializer, use C99 syntax
drivers/usb/gadget/function/u_audio.c:1138:27:
warning: obsolete array initializer, use C99 syntax
drivers/usb/gadget/function/u_audio.c:1145:25:
warning: obsolete array initializer, use C99 syntax

Also, fix two checkpatch.pl warnings:

WARNING: please, no spaces at the start of a line
+  [UAC_FBACK_CTRL] = {$

WARNING: please, no spaces at the start of a line
+  [UAC_MUTE_CTRL] = {$

Signed-off-by: Abhishek Tamboli &lt;abhishektamboli9@gmail.com&gt;
Reviewed-by: Ricardo B. Marliere &lt;ricardo@marliere.net&gt;
Link: https://lore.kernel.org/r/20240801190209.500373-1-abhishektamboli9@gmail.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: gadget: u_audio: Check return codes from usb_ep_enable and config_ep_by_speed.</title>
<updated>2024-07-31T08:38:57+00:00</updated>
<author>
<name>Chris Wulff</name>
<email>crwulff@gmail.com</email>
</author>
<published>2024-07-21T19:23:15+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=76a7bfc445b8e9893c091e24ccfd4f51dfdc0a70'/>
<id>urn:sha1:76a7bfc445b8e9893c091e24ccfd4f51dfdc0a70</id>
<content type='text'>
These functions can fail if descriptors are malformed, or missing,
for the selected USB speed.

Fixes: eb9fecb9e69b ("usb: gadget: f_uac2: split out audio core")
Fixes: 24f779dac8f3 ("usb: gadget: f_uac2/u_audio: add feedback endpoint support")
Cc: stable@vger.kernel.org
Signed-off-by: Chris Wulff &lt;crwulff@gmail.com&gt;
Link: https://lore.kernel.org/r/20240721192314.3532697-2-crwulff@gmail.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: gadget: u_audio: Clear uac pointer when freed.</title>
<updated>2024-05-04T16:26:08+00:00</updated>
<author>
<name>Chris Wulff</name>
<email>Chris.Wulff@biamp.com</email>
</author>
<published>2024-04-25T15:20:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=a2cf936ebef291ef7395172b9e2f624779fb6dc0'/>
<id>urn:sha1:a2cf936ebef291ef7395172b9e2f624779fb6dc0</id>
<content type='text'>
This prevents use of a stale pointer if functions are called after
g_cleanup that shouldn't be. This doesn't fix any races, but converts
a possibly silent kernel memory corruption into an obvious NULL pointer
dereference report.

Fixes: eb9fecb9e69b ("usb: gadget: f_uac2: split out audio core")
Signed-off-by: Chris Wulff &lt;chris.wulff@biamp.com&gt;
Link: https://lore.kernel.org/stable/CO1PR17MB54194226DA08BFC9EBD8C163E1172%40CO1PR17MB5419.namprd17.prod.outlook.com
Link: https://lore.kernel.org/r/CO1PR17MB54194226DA08BFC9EBD8C163E1172@CO1PR17MB5419.namprd17.prod.outlook.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: gadget: u_audio: Fix race condition use of controls after free during gadget unbind.</title>
<updated>2024-05-04T16:26:06+00:00</updated>
<author>
<name>Chris Wulff</name>
<email>Chris.Wulff@biamp.com</email>
</author>
<published>2024-04-25T15:18:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=1b739388aa3f8dfb63a9fca777e6dfa6912d0464'/>
<id>urn:sha1:1b739388aa3f8dfb63a9fca777e6dfa6912d0464</id>
<content type='text'>
Hang on to the control IDs instead of pointers since those are correctly
handled with locks.

Fixes: 8fe9a03f4331 ("usb: gadget: u_audio: Rate ctl notifies about current srate (0=stopped)")
Fixes: c565ad07ef35 ("usb: gadget: u_audio: Support multiple sampling rates")
Fixes: 02de698ca812 ("usb: gadget: u_audio: add bi-directional volume and mute support")
Signed-off-by: Chris Wulff &lt;chris.wulff@biamp.com&gt;
Link: https://lore.kernel.org/stable/CO1PR17MB5419C2BF44D400E4E620C1ADE1172%40CO1PR17MB5419.namprd17.prod.outlook.com
Link: https://lore.kernel.org/r/CO1PR17MB5419C2BF44D400E4E620C1ADE1172@CO1PR17MB5419.namprd17.prod.outlook.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: gadget: u_audio: Use snprintf() instead of sprintf()</title>
<updated>2024-03-26T09:45:52+00:00</updated>
<author>
<name>Christophe JAILLET</name>
<email>christophe.jaillet@wanadoo.fr</email>
</author>
<published>2024-03-23T06:57:05+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=54ada48481a134b5953bc37cafd1ad89cd68c133'/>
<id>urn:sha1:54ada48481a134b5953bc37cafd1ad89cd68c133</id>
<content type='text'>
In order to be consistent with other s[n]printf() usage in this file,
switch to snprintf() here as well.

Signed-off-by: Christophe JAILLET &lt;christophe.jaillet@wanadoo.fr&gt;
Link: https://lore.kernel.org/r/5703e697687e4a39059bf90659969ffc86b2cfbd.1711176701.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: gadget: u_audio: Use the 2-argument version of strscpy()</title>
<updated>2024-03-26T09:45:52+00:00</updated>
<author>
<name>Christophe JAILLET</name>
<email>christophe.jaillet@wanadoo.fr</email>
</author>
<published>2024-03-23T06:57:04+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=39c34568d786ae97180faf79ecfd31c3d0671ba6'/>
<id>urn:sha1:39c34568d786ae97180faf79ecfd31c3d0671ba6</id>
<content type='text'>
In order to be consistent with other strscpy() usage in this file and less
verbose, use the new 2-argument version of strscpy() which computes
auto-magically the size of the destination.

Signed-off-by: Christophe JAILLET &lt;christophe.jaillet@wanadoo.fr&gt;
Link: https://lore.kernel.org/r/e7fd0ec5a8b37799271c6d74c325cfb980d44181.1711176701.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: gadget: u_audio: Fix the size of a buffer in a strscpy() call</title>
<updated>2024-03-26T09:45:52+00:00</updated>
<author>
<name>Christophe JAILLET</name>
<email>christophe.jaillet@wanadoo.fr</email>
</author>
<published>2024-03-23T06:57:03+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=16fac242177c5eb374bb2caacc28793732857369'/>
<id>urn:sha1:16fac242177c5eb374bb2caacc28793732857369</id>
<content type='text'>
The size given to strscpy() is not consistent with the destination buffer
that is used. The size is related to 'driver' and the buffer is
'mixername'.

sizeof(card-&gt;mixername) is 80 and sizeof(card-&gt;driver) is 16, so in
theory this could lead to unneeded string truncation.

In practice, this is not the case because g_audio_setup() has only 2
callers. 'card_name' is either "UAC1_Gadget" or "UAC2_Gadget".

Anyway, using the correct size is cleaner and more future proof.

In order to be less verbose, use the new 2-argument version of strscpy()
which computes auto-magically the size of the destination.

Signed-off-by: Christophe JAILLET &lt;christophe.jaillet@wanadoo.fr&gt;
Link: https://lore.kernel.org/r/bf8a9353319566624f653531b80e5caf3d346ba1.1711176700.git.christophe.jaillet@wanadoo.fr
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: gadget: u_audio: don't let userspace block driver unbind</title>
<updated>2023-03-09T13:56:32+00:00</updated>
<author>
<name>Alvin Šipraga</name>
<email>alsi@bang-olufsen.dk</email>
</author>
<published>2023-03-02T16:36:47+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=6c67ed9ad9b83e453e808f9b31a931a20a25629b'/>
<id>urn:sha1:6c67ed9ad9b83e453e808f9b31a931a20a25629b</id>
<content type='text'>
In the unbind callback for f_uac1 and f_uac2, a call to snd_card_free()
via g_audio_cleanup() will disconnect the card and then wait for all
resources to be released, which happens when the refcount falls to zero.
Since userspace can keep the refcount incremented by not closing the
relevant file descriptor, the call to unbind may block indefinitely.
This can cause a deadlock during reboot, as evidenced by the following
blocked task observed on my machine:

  task:reboot  state:D stack:0   pid:2827  ppid:569    flags:0x0000000c
  Call trace:
   __switch_to+0xc8/0x140
   __schedule+0x2f0/0x7c0
   schedule+0x60/0xd0
   schedule_timeout+0x180/0x1d4
   wait_for_completion+0x78/0x180
   snd_card_free+0x90/0xa0
   g_audio_cleanup+0x2c/0x64
   afunc_unbind+0x28/0x60
   ...
   kernel_restart+0x4c/0xac
   __do_sys_reboot+0xcc/0x1ec
   __arm64_sys_reboot+0x28/0x30
   invoke_syscall+0x4c/0x110
   ...

The issue can also be observed by opening the card with arecord and
then stopping the process through the shell before unbinding:

  # arecord -D hw:UAC2Gadget -f S32_LE -c 2 -r 48000 /dev/null
  Recording WAVE '/dev/null' : Signed 32 bit Little Endian, Rate 48000 Hz, Stereo
  ^Z[1]+  Stopped                    arecord -D hw:UAC2Gadget -f S32_LE -c 2 -r 48000 /dev/null
  # echo gadget.0 &gt; /sys/bus/gadget/drivers/configfs-gadget/unbind
  (observe that the unbind command never finishes)

Fix the problem by using snd_card_free_when_closed() instead, which will
still disconnect the card as desired, but defer the task of freeing the
resources to the core once userspace closes its file descriptor.

Fixes: 132fcb460839 ("usb: gadget: Add Audio Class 2.0 Driver")
Cc: stable@vger.kernel.org
Signed-off-by: Alvin Šipraga &lt;alsi@bang-olufsen.dk&gt;
Reviewed-by: Ruslan Bilovol &lt;ruslan.bilovol@gmail.com&gt;
Reviewed-by: John Keeping &lt;john@metanate.com&gt;
Link: https://lore.kernel.org/r/20230302163648.3349669-1-alvin@pqrs.dk
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>usb: gadget: u_audio: clean up some inconsistent indenting</title>
<updated>2022-04-21T17:03:07+00:00</updated>
<author>
<name>Jiapeng Chong</name>
<email>jiapeng.chong@linux.alibaba.com</email>
</author>
<published>2022-04-07T06:24:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=b8a19881337678c02bb3d72ae821602e1a4c377d'/>
<id>urn:sha1:b8a19881337678c02bb3d72ae821602e1a4c377d</id>
<content type='text'>
Eliminate the follow smatch warning:

drivers/usb/gadget/function/u_audio.c:1182 g_audio_setup() warn:
inconsistent indenting.

Reported-by: Abaci Robot &lt;abaci@linux.alibaba.com&gt;
Signed-off-by: Jiapeng Chong &lt;jiapeng.chong@linux.alibaba.com&gt;
Link: https://lore.kernel.org/r/20220407062410.89214-1-jiapeng.chong@linux.alibaba.com
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
</feed>
