Linux Sound subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ian Rogers" <irogers@google.com>
Cc: linux-sound@vger.kernel.org
Subject: Re: [PATCH] ASoC: rt1320-sdw: Reject unknown dev_id in FU Capture Volume handlers
Date: Thu, 19 Nov 2026 17:23:00 +0000	[thread overview]
Message-ID: <sashiko-outbox-223688@kernel.org> (raw)
In-Reply-To: <20261119170656.1522183-1-irogers@google.com>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] ASoC: codecs: unsigned cast bypasses bounds check in
  set_gain_put() [1]
--

commit 6b4eb08972e9d693f4ba90820d49635baaaa320b
Author: Ian Rogers <irogers@google.com>

ASoC: rt1320-sdw: Reject unknown dev_id in FU Capture Volume handlers

This commit adds default branches returning -EINVAL to the dev_id switch
statements in rt1320_set_gain_put() and rt1320_set_gain_get() to avoid
using uninitialized stack variables when the device ID is not yet
populated or unrecognized.

> diff --git a/sound/soc/codecs/rt1320-sdw.c b/sound/soc/codecs/rt1320-sdw.c
> index 19079212ba6c0..6724012d5c09d 100644
> --- a/sound/soc/codecs/rt1320-sdw.c
> +++ b/sound/soc/codecs/rt1320-sdw.c
> @@ -2829,6 +2829,8 @@ static int rt1320_set_gain_put(struct snd_kcontrol *kcontrol,
>  			reg_base = SDW_SDCA_CTL(FUNC_NUM_MIC, RT1320_SDCA_ENT_FU113, RT1320_SDCA_CTL_FU_VOLUME, CH_01);
>  			regmap_read(rt1320->mbq_regmap, reg_base + i, &regvalue[i]);
>  			break;
> +		default:
> +			return -EINVAL;
>  		}
>  
>  		gain_val[i] = ucontrol->value.integer.value[i];

[Severity: High]
This problem wasn't introduced by this patch, but can a negative
ucontrol->value.integer.value[i] wrap when assigned to the unsigned
gain_val[i] [1]?  A negative value from userspace converts to a
large unsigned integer and gets clamped to p->max by the following
gain_val[i] > p->max check, setting the gain to maximum instead of
rejecting or clamping it to the minimum.

[1] https://sashiko.dev/#/bug/linux-4e6d0e9a-edf1-4f06-b366-c7939979db0e

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261119170656.1522183-1-irogers@google.com?part=1

      reply	other threads:[~2026-11-19 17:23 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 17:06 [PATCH] ASoC: rt1320-sdw: Reject unknown dev_id in FU Capture Volume handlers Ian Rogers
2026-11-19 17:23 ` 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-223688@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=irogers@google.com \
    --cc=linux-sound@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox