Re: [PATCH v4 5/7] ALSA: usb-audio: us144mkii: Add MIDI support and mixer controls

From: Takashi Iwai
Date: Thu Aug 14 2025 - 04:03:35 EST


On Wed, 13 Aug 2025 15:15:16 +0200,
Šerif Rami wrote:
>
> +static int tascam_samplerate_get(struct snd_kcontrol *kcontrol,
> + struct snd_ctl_elem_value *ucontrol)
> +{
> + struct tascam_card *tascam =
> + (struct tascam_card *)snd_kcontrol_chip(kcontrol);
> + u8 *buf __free(kfree) = NULL;
> + int err;
> + u32 rate = 0;
> +
> + guard(spinlock_irqsave)(&tascam->lock);
> + if (tascam->current_rate > 0) {
> + ucontrol->value.integer.value[0] = tascam->current_rate;
> + return 0;
> + }
> + // Lock is released here before kmalloc and usb_control_msg

No, the lock isn't released!
You must use scoped_guard() in this case.

> +void tascam_midi_out_urb_complete(struct urb *urb)
> +{
....
> + {
> + guard(spinlock_irqsave)(&tascam->midi_out_lock);

Use scoped_guard().

> +static void tascam_midi_out_work_handler(struct work_struct *work)
> +{
....
> + {
> + guard(spinlock_irqsave)(&tascam->midi_out_lock);

Ditto.

> + {
> + guard(spinlock_irqsave)(&tascam->midi_out_lock);

Here, too.

Try to grep and check similar patterns are seen in other patches,
too. I might have overlooked.


thanks,

Takashi