All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Takashi Iwai" <tiwai@suse.de>, linux-sound@vger.kernel.org
Subject: Re: [PATCH] ALSA: usb-audio: Fix missing 64bit conversions for 64 channel enhancement
Date: Wed, 02 Dec 2026 14:26:50 +0000	[thread overview]
Message-ID: <sashiko-outbox-245958@kernel.org> (raw)
In-Reply-To: <20261202141631.688337-1-tiwai@suse.de>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] ALSA: usb-audio: unconverted 32-bit BIT(j) in
  parse_audio_feature_unit()
--

commit c7574dcbffc09488f93abce794f2df8e79705058
Author: Takashi Iwai <tiwai@suse.de>

ALSA: usb-audio: Fix missing 64bit conversions for 64 channel enhancement

This commit converts channel bitmasks and BIT() usages in the USB audio
mixer to 64-bit types and BIT_U64() to support up to 64 mixer channels.

> diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c
> index 37850f34caaea..a16c11a7b79fb 100644
> --- a/sound/usb/mixer.c
> +++ b/sound/usb/mixer.c

[ ... ]

> @@ -2317,7 +2317,7 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid,
>  	} else { /* UAC_VERSION_2/3 */
>  		for (i = 0; i < ARRAY_SIZE(audio_feature_info); i++) {
>  			u64 ch_bits = 0;
> -			unsigned int ch_read_only = 0;
> +			u64 ch_read_only = 0;
>  			int control = audio_feature_info[i].control;
>  
>  			for (j = 0; j < channels; j++) {
> @@ -2326,9 +2326,9 @@ static int parse_audio_feature_unit(struct mixer_build *state, int unitid,
>  				mask = snd_usb_combine_bytes(bmaControls +
>  							     csize * (j+1), csize);
>  				if (uac_v2v3_control_is_readable(mask, control)) {
> -					ch_bits |= BIT(j);
> +					ch_bits |= BIT_U64(j);
>  					if (!uac_v2v3_control_is_writeable(mask, control))
> -						ch_read_only |= BIT(j);
> +						ch_read_only |= BIT_U64(j);
>  				}
>  			}
>  

[Severity: Medium]
Should the UAC_VERSION_1 branch right above this in
parse_audio_feature_unit() also use BIT_U64(j) when setting ch_bits?

sound/usb/mixer.c:parse_audio_feature_unit() {
    ...
			for (j = 0; j < channels; j++) {
				unsigned int mask;

				mask = snd_usb_combine_bytes(bmaControls +
							     csize * (j+1), csize);
				if (mask & BIT(i))
					ch_bits |= BIT(j);
			}
    ...
}

On 32-bit architectures, BIT(j) shifts a 32-bit unsigned long, so UAC1
feature units with more than 32 channels hit a shift-out-of-bounds for
j >= 32 and fail to populate the upper 32 bits of ch_bits.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261202141631.688337-1-tiwai@suse.de?part=1

      reply	other threads:[~2026-12-02 14:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02 14:16 [PATCH] ALSA: usb-audio: Fix missing 64bit conversions for 64 channel enhancement Takashi Iwai
2026-12-02 14:26 ` sashiko-bot [this message]

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-245958@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=linux-sound@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tiwai@suse.de \
    /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.