All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ismaïl Bahloul" <i.bahloul01@gmail.com>, linux-sound@vger.kernel.org
Cc: linux-usb@vger.kernel.org
Subject: Re: [PATCH v8 4/8] ALSA: usb: babyfacepro: add routing flags and varispeed pitch
Date: Thu, 05 Nov 2026 15:32:36 +0000	[thread overview]
Message-ID: <sashiko-outbox-199313@kernel.org> (raw)
In-Reply-To: <20261105151553.223722-5-i.bahloul01@gmail.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] ALSA: usb: babyfacepro: out-of-bounds value[1] write in bf_loopback_get()
- [Low] ALSA: usb: babyfacepro: leftover contradictory comment above bf_out_reg8()
--

commit bc91f1e348293fb57b62c700b674ce38c7dc5791
Author: Ismaïl Bahloul <i.bahloul01@gmail.com>

ALSA: usb: babyfacepro: add routing flags and varispeed pitch

This commit adds ALSA mixer controls and state persistence for routing flags
(loopback, AN 1>2, sample clock source, optical out format, AN1/2 link, MS
processor, DIM, width, and FX send) and varispeed pitch on the RME Babyface
Pro.

> diff --git a/sound/usb/babyfacepro/babyfacepro-ctl.c b/sound/usb/babyfacepro/babyfacepro-ctl.c
> index fe6266ea118e6..5482b6f09b73a 100644
> --- a/sound/usb/babyfacepro/babyfacepro-ctl.c
> +++ b/sound/usb/babyfacepro/babyfacepro-ctl.c

[ ... ]

> @@ -325,6 +329,33 @@ static int bf_master_get(struct snd_kcontrol *kctl,
>  	return 0;
>  }
>  
> +/* The master step to put on the wire.  The cache keeps the real
> + * volume: mute wins, and DIM is the fixed -20 dB step on the Phones
> + * pair, so every writer derives the wire value the same way.
> + */
> +/* The two master registers to put on the wire.  The cache keeps the
> + * real volume: mute wins, and DIM is the exact -20 dB pair the
> + * hardware's own button writes (0xcb / 0x0333, cap_dim2.pcap), not the
> + * master curve's value at that step.
> + */
> +static u8 bf_out_reg8(bool muted, bool dim, u16 step)

[Severity: Low]
This isn't a bug, but is the first comment block above bf_out_reg8() in
sound/usb/babyfacepro/babyfacepro-ctl.c a leftover from an earlier draft
that was meant to be replaced by the second comment block?

[ ... ]

> @@ -1278,3 +1305,679 @@ int babyface_create_preamp(struct snd_usb_babyface *chip)

[ ... ]

> +static int bf_loopback_get(struct snd_kcontrol *kctl,
> +			   struct snd_ctl_elem_value *ucontrol)
> +{
> +	struct snd_usb_babyface *chip = snd_kcontrol_chip(kctl);
> +	int out = kctl->private_value;
> +
> +	ucontrol->value.integer.value[0] = chip->loopback[out];
> +	ucontrol->value.integer.value[1] = chip->loopback[out];
> +	return 0;
> +}

[Severity: Medium]
Does bf_loopback_get() in sound/usb/babyfacepro/babyfacepro-ctl.c write
past the declared element count when populating
ucontrol->value.integer.value[1]?

In babyface_create_flags(), the Loopback Switch controls are registered with
.info = bf_mute_info and .get = bf_loopback_get:

	for (i = 0; i < 6; i++) {
		kctl = snd_ctl_new1(&(struct snd_kcontrol_new){
			.iface = SNDRV_CTL_ELEM_IFACE_MIXER,
			.name = "Loopback Switch",
			.index = i,
			.info = bf_mute_info,
			.get = bf_loopback_get,
			.put = bf_loopback_put,
			.private_value = i,
		}, chip);

However, bf_mute_info() sets uinfo->count = 1:

	uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
	/* One switch for the pair: bf_mute_put() writes both channels
	 * together, so a count of 2 would silently ignore value[1].
	 */
	uinfo->count = 1;

When userspace reads the control via snd_ctl_elem_read() -> bf_loopback_get()
with CONFIG_SND_CTL_DEBUG enabled, the ALSA control core poisons the buffer
past info.count with fill_remaining_elem_value() and then checks it in
sanity_check_elem_value(). Because bf_loopback_get() (like bf_mute_get())
writes ucontrol->value.integer.value[1] on a count = 1 control,
sanity_check_elem_value() logs an access overflow error and fails the read
with -EINVAL.

Should bf_loopback_get() only write ucontrol->value.integer.value[0] (or use
bf_switch_info and a single-value get, and similarly in bf_mute_get())?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261105151553.223722-1-i.bahloul01@gmail.com?part=4

  reply	other threads:[~2026-11-05 15:32 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05 15:15 [PATCH v8 0/8] ALSA: usb: add RME Babyface Pro driver (proprietary mode) Ismaïl Bahloul
2026-11-05 15:15 ` [PATCH v8 1/8] ALSA: usb: add RME Babyface Pro driver core (probe, PCM stream) Ismaïl Bahloul
2026-11-05 16:24   ` sashiko-bot
2026-11-05 15:15 ` [PATCH v8 2/8] ALSA: usb: babyfacepro: add output masters and crosspoint routing Ismaïl Bahloul
2026-11-05 15:31   ` sashiko-bot
2026-11-05 15:15 ` [PATCH v8 3/8] ALSA: usb: babyfacepro: add mic preamp, phantom/pad and input trim Ismaïl Bahloul
2026-11-05 15:32   ` sashiko-bot
2026-11-05 15:15 ` [PATCH v8 4/8] ALSA: usb: babyfacepro: add routing flags and varispeed pitch Ismaïl Bahloul
2026-11-05 15:32   ` sashiko-bot [this message]
2026-11-05 15:15 ` [PATCH v8 5/8] ALSA: usb: babyfacepro: add S3 suspend/resume Ismaïl Bahloul
2026-11-05 16:45   ` sashiko-bot
2026-11-05 15:15 ` [PATCH v8 6/8] ALSA: usb: babyfacepro: add the front-panel poll and controls Ismaïl Bahloul
2026-11-05 17:03   ` sashiko-bot
2026-11-05 15:15 ` [PATCH v8 7/8] ALSA: usb: babyfacepro: add the hardware DSP EQ Ismaïl Bahloul
2026-11-05 17:19   ` sashiko-bot
2026-11-05 15:15 ` [PATCH v8 8/8] Documentation: sound: add the Babyface Pro proprietary-mode design doc Ismaïl Bahloul
2026-11-05 17:21   ` sashiko-bot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-199313@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=i.bahloul01@gmail.com \
    --cc=linux-sound@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.