From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94F5B18B491; Tue, 10 Sep 2024 10:01:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725962463; cv=none; b=fuarA2xVGOP8KMidDV3TISDBnL7SJSkV4NEMqjv86CRR0QE9qMxE69skXbM/CkCtOijcV04qO67ilmTKsPhDKfBm04qku/nHzSNgvg75ePdztFTeXeuX7YF335qc+is8DuNJ5dBjpIVO4xYO/o4C1rNoSjZf4Slm0B7kjFs7NUE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725962463; c=relaxed/simple; bh=rIj1dCZttI+tGvdK2mWqse0vcEMGoVBPvHyKm8rC/kw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AYYcZal0fPnzmaz1eeWddTZgReQ08epUQIdWc5eZEdTF26vGx3jKcvkjsINFUPS+djYFjrzsB3JPp9r6XRfIi/m2zzIjklmBV5rYZcg5RCtS4QrhsWnQuog6yqVfjna67MHrXprTLBw+dHV3Xf3NDl5QXSVMzan4p1AEhxsCRx4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=IOz7l/yk; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="IOz7l/yk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 17EB1C4CEC3; Tue, 10 Sep 2024 10:01:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1725962463; bh=rIj1dCZttI+tGvdK2mWqse0vcEMGoVBPvHyKm8rC/kw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IOz7l/ykplKsFNMQV4NAKntIY8L5srvTowi3HYSmPqkGwWJwREWCe6q6Ayp+kALXw l/XaiJZSJaJ430lY4bCT0oRIDZVkxjZCqGrvvMAmnWGPtPNvbJY4KyA1nB7QZ0Owgq OUrZ1d893tzxgOOW3/sY5MM5/ieJUCnZXurozTDo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jaroslav Kysela , Takashi Iwai , Sasha Levin Subject: [PATCH 5.4 043/121] ALSA: hda: Add input value sanity checks to HDMI channel map controls Date: Tue, 10 Sep 2024 11:31:58 +0200 Message-ID: <20240910092547.786408666@linuxfoundation.org> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240910092545.737864202@linuxfoundation.org> References: <20240910092545.737864202@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Takashi Iwai [ Upstream commit 6278056e42d953e207e2afd416be39d09ed2d496 ] Add a simple sanity check to HD-audio HDMI Channel Map controls. Although the value might not be accepted for the actual connection, we can filter out some bogus values beforehand, and that should be enough for making kselftest happier. Reviewed-by: Jaroslav Kysela Signed-off-by: Takashi Iwai Link: https://lore.kernel.org/20240616073454.16512-7-tiwai@suse.de Signed-off-by: Sasha Levin --- sound/hda/hdmi_chmap.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/sound/hda/hdmi_chmap.c b/sound/hda/hdmi_chmap.c index 2efee794cac6..79ccec2da387 100644 --- a/sound/hda/hdmi_chmap.c +++ b/sound/hda/hdmi_chmap.c @@ -753,6 +753,20 @@ static int hdmi_chmap_ctl_get(struct snd_kcontrol *kcontrol, return 0; } +/* a simple sanity check for input values to chmap kcontrol */ +static int chmap_value_check(struct hdac_chmap *hchmap, + const struct snd_ctl_elem_value *ucontrol) +{ + int i; + + for (i = 0; i < hchmap->channels_max; i++) { + if (ucontrol->value.integer.value[i] < 0 || + ucontrol->value.integer.value[i] > SNDRV_CHMAP_LAST) + return -EINVAL; + } + return 0; +} + static int hdmi_chmap_ctl_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { @@ -764,6 +778,10 @@ static int hdmi_chmap_ctl_put(struct snd_kcontrol *kcontrol, unsigned char chmap[8], per_pin_chmap[8]; int i, err, ca, prepared = 0; + err = chmap_value_check(hchmap, ucontrol); + if (err < 0) + return err; + /* No monitor is connected in dyn_pcm_assign. * It's invalid to setup the chmap */ -- 2.43.0