From patchwork Sun Jun 16 07:34:42 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 13699451 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C567B178CC9; Sun, 16 Jun 2024 07:34:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718523278; cv=none; b=tv+f80D8bldeQ3xubnPjwkBrlg/DWaFYZH3MPBr5IcM4d8/+juBCVDGv2ei6dW0gFo2G4+oGyW01iUj5Na9YNwVW9o2i+WXb5Z6e1m6QF+LFlacwScix7Lv4dbcgpU0NC4bwuerj0MJgh2yADpQa26EkPgfnT6WnNvlrcv9KS8I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718523278; c=relaxed/simple; bh=w/IWp6nSo64sVIfX4UwPn3vOfavqx0Ypo3pzKZ2Tr1Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N8LpzsslfyurP8Kj1NOGrEks2gNqg3Q3EPeZ7R2TvevwraOnlfiauQD+uMvrF8+K74GtNbA7k1111yPnnz1gX1ZsYOQLQW/oa33Qov4JvnB6hAN852Tw5IXwIRu4uyVCykV9YS0J2EdAc0Y1o9xRChNfonWX87vOL/dDvzDO8YM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=hCL1xJR+; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=bGb5lDpM; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=hCL1xJR+; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=bGb5lDpM; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="hCL1xJR+"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="bGb5lDpM"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="hCL1xJR+"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="bGb5lDpM" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id B8DF85CCBE; Sun, 16 Jun 2024 07:34:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718523274; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FEwFJHDU5Fva9mbGeUjJ0f/3QZ/OGfA9VGgdBIwLBCE=; b=hCL1xJR+2Lxf91hfbj7fNsyePUh9XOOY++dMoAXFJWiIIYbTr7nWUWGedw4N2a4pF8psDv KY6KzNoiCMs0OZpAKpWR92nwAKewzwgkHgYQdmkvrYjeDGe/DZ5HyytZuKGhjT1ziadDYL ESaMjsthvy/Gj1WUZfYPR+CJ/9I/jGg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718523274; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FEwFJHDU5Fva9mbGeUjJ0f/3QZ/OGfA9VGgdBIwLBCE=; b=bGb5lDpMHGuLoDLr4a9IX/L5E/14+AyTqnTsRAY0KsR1rTy6A/3yocV7xR8jTfs+9XfNoq AgveAjALZifXvLBg== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=hCL1xJR+; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=bGb5lDpM DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718523274; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FEwFJHDU5Fva9mbGeUjJ0f/3QZ/OGfA9VGgdBIwLBCE=; b=hCL1xJR+2Lxf91hfbj7fNsyePUh9XOOY++dMoAXFJWiIIYbTr7nWUWGedw4N2a4pF8psDv KY6KzNoiCMs0OZpAKpWR92nwAKewzwgkHgYQdmkvrYjeDGe/DZ5HyytZuKGhjT1ziadDYL ESaMjsthvy/Gj1WUZfYPR+CJ/9I/jGg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718523274; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FEwFJHDU5Fva9mbGeUjJ0f/3QZ/OGfA9VGgdBIwLBCE=; b=bGb5lDpMHGuLoDLr4a9IX/L5E/14+AyTqnTsRAY0KsR1rTy6A/3yocV7xR8jTfs+9XfNoq AgveAjALZifXvLBg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 7BB0F13ABC; Sun, 16 Jun 2024 07:34:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id AFPWHIqVbmYVCwAAD6G6ig (envelope-from ); Sun, 16 Jun 2024 07:34:34 +0000 From: Takashi Iwai To: linux-sound@vger.kernel.org Cc: Paul Menzel , Mark Brown , Jaroslav Kysela , Takashi Sakamoto , linux-kselftest@vger.kernel.org Subject: [PATCH v3 1/6] ALSA: vmaster: Return error for invalid input values Date: Sun, 16 Jun 2024 09:34:42 +0200 Message-ID: <20240616073454.16512-2-tiwai@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240616073454.16512-1-tiwai@suse.de> References: <20240616073454.16512-1-tiwai@suse.de> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spamd-Result: default: False [-5.01 / 50.00]; BAYES_HAM(-3.00)[99.99%]; DWL_DNSWL_MED(-2.00)[suse.de:dkim]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCVD_COUNT_TWO(0.00)[2]; DKIM_TRACE(0.00)[suse.de:+]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns] X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: B8DF85CCBE X-Spam-Flag: NO X-Spam-Score: -5.01 X-Spam-Level: So far the vmaster code has been tolerant about the input values and accepts any values by correcting internally. But now our own selftest starts complaining about this behavior, so let's be picky and change the behavior to return -EINVAL for invalid input values instead. Reported-by: Paul Menzel Closes: https://lore.kernel.org/r/1d44be36-9bb9-4d82-8953-5ae2a4f09405@molgen.mpg.de Reviewed-by: Jaroslav Kysela Signed-off-by: Takashi Iwai --- sound/core/vmaster.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/sound/core/vmaster.c b/sound/core/vmaster.c index 04a57f7be6ea..c657659b236c 100644 --- a/sound/core/vmaster.c +++ b/sound/core/vmaster.c @@ -198,6 +198,12 @@ static int follower_put(struct snd_kcontrol *kcontrol, err = follower_init(follower); if (err < 0) return err; + for (ch = 0; ch < follower->info.count; ch++) { + if (ucontrol->value.integer.value[ch] < follower->info.min_val || + ucontrol->value.integer.value[ch] > follower->info.max_val) + return -EINVAL; + } + for (ch = 0; ch < follower->info.count; ch++) { if (follower->vals[ch] != ucontrol->value.integer.value[ch]) { changed = 1; @@ -365,6 +371,8 @@ static int master_put(struct snd_kcontrol *kcontrol, new_val = ucontrol->value.integer.value[0]; if (new_val == old_val) return 0; + if (new_val < master->info.min_val || new_val > master->info.max_val) + return -EINVAL; err = sync_followers(master, old_val, new_val); if (err < 0) From patchwork Sun Jun 16 07:34:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 13699452 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB18A178CDF; Sun, 16 Jun 2024 07:34:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718523278; cv=none; b=mb5iL94qKIvwd9PTQn2qqDDbWFvaD4mkxdzzVXwSD4APiVfOtMsi/tdKpHu0kFvSzWJ3OUMIWMhAyvip813Em28V0hM857c9UwKxM8BRvM3ihlvds7www2zkqTcGXdI75M3FsjvyXjmawlp9uOt+moJISbTyK/KkuA1vun8e3WA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718523278; c=relaxed/simple; bh=jhHFFFxw+TQY8tMMgflq+/MItjuQAQ7L4GPqyFiQCSs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kYVrjRdH9pISwJQjxkdfmHPuspQUkVGQNdX/I07mIm3S3FWxzpPJZyfQzsFcyPeKQ8N3hXUeVL1ErpBsbPkHjb+eb2mm3FXGHolXOMVyKcVkShNpmUt+CeKhsFCZX9SlZxuoyyAA3ZY/Mog+Kd3+oyJgwAmMivqx/SWtDNa+Q2o= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=zp0o5oA/; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=zqMzCaWQ; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=zp0o5oA/; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=zqMzCaWQ; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="zp0o5oA/"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="zqMzCaWQ"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="zp0o5oA/"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="zqMzCaWQ" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 057EA3506C; Sun, 16 Jun 2024 07:34:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718523275; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/949HUx6nZDACgffMOe488Rg+F1Zwk2M5jAJ2WOsB34=; b=zp0o5oA/J1jraVXKAb5sM319KV8YKvN7cIiUu6yPw932Ro/hDm4u2kmvOX+/cEwmBsL2x+ NWAp61Zlp05tDUGcaeaIwb/wS4imaKs1e7xYYit6OS2pWXy28jKj9ATuUoODsU5aGkJzHc 7NtciDoUcIdxWIZtZeu5c4+wA0FweCk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718523275; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/949HUx6nZDACgffMOe488Rg+F1Zwk2M5jAJ2WOsB34=; b=zqMzCaWQEet7xwuaMmVJI93d9m7yAEbw0g/WEANx+I4HDLS8q7FUSUF+JZoExAg4Vk9LV0 qQB26g+Le6gJ9JAA== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="zp0o5oA/"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=zqMzCaWQ DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718523275; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/949HUx6nZDACgffMOe488Rg+F1Zwk2M5jAJ2WOsB34=; b=zp0o5oA/J1jraVXKAb5sM319KV8YKvN7cIiUu6yPw932Ro/hDm4u2kmvOX+/cEwmBsL2x+ NWAp61Zlp05tDUGcaeaIwb/wS4imaKs1e7xYYit6OS2pWXy28jKj9ATuUoODsU5aGkJzHc 7NtciDoUcIdxWIZtZeu5c4+wA0FweCk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718523275; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/949HUx6nZDACgffMOe488Rg+F1Zwk2M5jAJ2WOsB34=; b=zqMzCaWQEet7xwuaMmVJI93d9m7yAEbw0g/WEANx+I4HDLS8q7FUSUF+JZoExAg4Vk9LV0 qQB26g+Le6gJ9JAA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id BC86013AB9; Sun, 16 Jun 2024 07:34:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 0IDDLIqVbmYVCwAAD6G6ig (envelope-from ); Sun, 16 Jun 2024 07:34:34 +0000 From: Takashi Iwai To: linux-sound@vger.kernel.org Cc: Paul Menzel , Mark Brown , Jaroslav Kysela , Takashi Sakamoto , linux-kselftest@vger.kernel.org Subject: [PATCH v3 2/6] ALSA: hda: Return -EINVAL for invalid volume/switch inputs Date: Sun, 16 Jun 2024 09:34:43 +0200 Message-ID: <20240616073454.16512-3-tiwai@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240616073454.16512-1-tiwai@suse.de> References: <20240616073454.16512-1-tiwai@suse.de> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Queue-Id: 057EA3506C X-Spam-Score: -5.01 X-Spam-Level: X-Spam-Flag: NO X-Spamd-Result: default: False [-5.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; DWL_DNSWL_MED(-2.00)[suse.de:dkim]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCVD_COUNT_TWO(0.00)[2]; DKIM_TRACE(0.00)[suse.de:+]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns] X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org So far the HD-audio driver has been tolerant about the input values and accepts any values by correcting the amp volume and switch values internally. But now our own selftest starts complaining about this behavior, so let's be picky and change the behavior to return -EINVAL for invalid input values instead. Reported-by: Paul Menzel Closes: https://lore.kernel.org/r/1d44be36-9bb9-4d82-8953-5ae2a4f09405@molgen.mpg.de Reviewed-by: Jaroslav Kysela Signed-off-by: Takashi Iwai --- sound/pci/hda/hda_codec.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 325e8f0b99a8..3dd1bda0c5c6 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -1496,7 +1496,7 @@ update_amp_value(struct hda_codec *codec, hda_nid_t nid, /* ofs = 0: raw max value */ maxval = get_amp_max_value(codec, nid, dir, 0); if (val > maxval) - val = maxval; + return -EINVAL; return snd_hda_codec_amp_update(codec, nid, ch, dir, idx, HDA_AMP_VOLMASK, val); } @@ -1547,13 +1547,21 @@ int snd_hda_mixer_amp_volume_put(struct snd_kcontrol *kcontrol, unsigned int ofs = get_amp_offset(kcontrol); long *valp = ucontrol->value.integer.value; int change = 0; + int err; if (chs & 1) { - change = update_amp_value(codec, nid, 0, dir, idx, ofs, *valp); + err = update_amp_value(codec, nid, 0, dir, idx, ofs, *valp); + if (err < 0) + return err; + change |= err; valp++; } - if (chs & 2) - change |= update_amp_value(codec, nid, 1, dir, idx, ofs, *valp); + if (chs & 2) { + err = update_amp_value(codec, nid, 1, dir, idx, ofs, *valp); + if (err < 0) + return err; + change |= err; + } return change; } EXPORT_SYMBOL_GPL(snd_hda_mixer_amp_volume_put); @@ -2149,15 +2157,20 @@ int snd_hda_mixer_amp_switch_put(struct snd_kcontrol *kcontrol, int change = 0; if (chs & 1) { + if (*valp < 0 || *valp > 1) + return -EINVAL; change = snd_hda_codec_amp_update(codec, nid, 0, dir, idx, HDA_AMP_MUTE, *valp ? 0 : HDA_AMP_MUTE); valp++; } - if (chs & 2) + if (chs & 2) { + if (*valp < 0 || *valp > 1) + return -EINVAL; change |= snd_hda_codec_amp_update(codec, nid, 1, dir, idx, HDA_AMP_MUTE, *valp ? 0 : HDA_AMP_MUTE); + } hda_call_check_power_status(codec, nid); return change; } From patchwork Sun Jun 16 07:34:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 13699454 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 364A7178CE2; Sun, 16 Jun 2024 07:34:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718523278; cv=none; b=h+0kPgWycQsBZHhuglXvM5PsIOaUaqI8yH1Q4To7qXEkHL2lRa+wlRtSXJ7sZuUAuGnVl8Tyr4uPCfxWsDdljj8+vrrYis+qcGBwRGhF2++1LATyk9J9tgFpXA+dt+j6Asclpa6eZE0pByUwmR8L2J9H6k3B06LOvwlQyFG3gDQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718523278; c=relaxed/simple; bh=ewFCmvWdTHUP5TXobHOgdvphPMgBV6JL4KA/1hdYfoc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=J8IVGJLUCS431Q6sZOQm0KxPzdGPW/b+61fb/cNsPeOpSu8oacipD6hbrSnJEy98o1xHzJwZOcZywquezQH9qM+atJIoq5vjtHcCDha8TwQJR3EQFpB3JvzkdYZ7cToWxT6WKpZEQubAVfIRzljQWyT5T/21GR/4ph5opx/ysro= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=mv8qOk+q; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=gPIKth/H; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=mv8qOk+q; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=gPIKth/H; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="mv8qOk+q"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="gPIKth/H"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="mv8qOk+q"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="gPIKth/H" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 3C1413506D; Sun, 16 Jun 2024 07:34:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718523275; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qrkTl4bH7rGV7b1L3DA5zVOqzeTHEo1PLxkVkHx1bOY=; b=mv8qOk+qAEXWyVxD+Prqbw5hMQ/I4ml24EMkSogPvhC/TiMA+amX72JnnV/x+R/8hkLmoT Qhta0rlH5ndHWjeSdnvIAo48TEdS9ZI2m/blMk27IpcWNdhsXRoLQBctcrjffcUi8vuNO1 snpdeFrs45HOe+Abz9PkeQfMDeh/hOw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718523275; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qrkTl4bH7rGV7b1L3DA5zVOqzeTHEo1PLxkVkHx1bOY=; b=gPIKth/H+VIqqi33dw+pggarQ9DhF97auNo7U2tclTjJlx929g5YRVcOZWhMteeAfNeDly R1Li83k6QUgoNPCg== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718523275; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qrkTl4bH7rGV7b1L3DA5zVOqzeTHEo1PLxkVkHx1bOY=; b=mv8qOk+qAEXWyVxD+Prqbw5hMQ/I4ml24EMkSogPvhC/TiMA+amX72JnnV/x+R/8hkLmoT Qhta0rlH5ndHWjeSdnvIAo48TEdS9ZI2m/blMk27IpcWNdhsXRoLQBctcrjffcUi8vuNO1 snpdeFrs45HOe+Abz9PkeQfMDeh/hOw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718523275; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qrkTl4bH7rGV7b1L3DA5zVOqzeTHEo1PLxkVkHx1bOY=; b=gPIKth/H+VIqqi33dw+pggarQ9DhF97auNo7U2tclTjJlx929g5YRVcOZWhMteeAfNeDly R1Li83k6QUgoNPCg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 05D5713ABC; Sun, 16 Jun 2024 07:34:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id +JUDAIuVbmYVCwAAD6G6ig (envelope-from ); Sun, 16 Jun 2024 07:34:34 +0000 From: Takashi Iwai To: linux-sound@vger.kernel.org Cc: Paul Menzel , Mark Brown , Jaroslav Kysela , Takashi Sakamoto , linux-kselftest@vger.kernel.org Subject: [PATCH v3 3/6] ALSA: control: Apply sanity check of input values for user elements Date: Sun, 16 Jun 2024 09:34:44 +0200 Message-ID: <20240616073454.16512-4-tiwai@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240616073454.16512-1-tiwai@suse.de> References: <20240616073454.16512-1-tiwai@suse.de> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-Spam-Score: -2.80 X-Spam-Level: Although we have already a mechanism for sanity checks of input values for control writes, it's not applied unless the kconfig CONFIG_SND_CTL_INPUT_VALIDATION is set due to the performance reason. Nevertheless, it still makes sense to apply the same check for user elements despite of its cost, as that's the only way to filter out the invalid values; the user controls are handled solely in ALSA core code, and there is no corresponding driver, after all. This patch adds the same input value validation for user control elements at its put callback. The kselftest will be happier with this change, as the incorrect values will be bailed out now with errors. For other normal controls, the check is applied still only when CONFIG_SND_CTL_INPUT_VALIDATION is set. Reported-by: Paul Menzel Closes: https://lore.kernel.org/r/1d44be36-9bb9-4d82-8953-5ae2a4f09405@molgen.mpg.de Reviewed-by: Jaroslav Kysela Reviewed-by: Mark Brown Reviewed-by: Takashi Sakamoto Signed-off-by: Takashi Iwai --- sound/core/control.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sound/core/control.c b/sound/core/control.c index fb0c60044f7b..1dd2337e2930 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -1480,12 +1480,16 @@ static int snd_ctl_elem_user_get(struct snd_kcontrol *kcontrol, static int snd_ctl_elem_user_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) { - int change; + int err, change; struct user_element *ue = kcontrol->private_data; unsigned int size = ue->elem_data_size; char *dst = ue->elem_data + snd_ctl_get_ioff(kcontrol, &ucontrol->id) * size; + err = sanity_check_input_values(ue->card, ucontrol, &ue->info, false); + if (err < 0) + return err; + change = memcmp(&ucontrol->value, dst, size) != 0; if (change) memcpy(dst, &ucontrol->value, size); From patchwork Sun Jun 16 07:34:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 13699453 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38D02178CF2; Sun, 16 Jun 2024 07:34:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718523278; cv=none; b=jFSiaD5LXWe/y/0tp0ht7ebdr7w+Udood2RAvSOprBX/RyWMIHRNxDpVi4O28QvppwuKKMxBHsBJt2UHDQlk5g/B9kFPa+033CbZRWq13izSk/wmYCIEFW2xeeTRbv95LricM0a2KN6AUsR1w5dxOu0ZXCodS262Lf7l0ZIMfSA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718523278; c=relaxed/simple; bh=/Ce9566tcfILguU+BY2r/o1lpX2zpSDiCC5gijAJWTs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hi0xug2PeDtyppMFC6OlWvNdunDbWYDJmruPqOpbDDcPrufFKECfVaCn6SRbpjB1I2k++murkujiIIO6OPYJsyMCqEFBGgi8SqXDWej3OfhyCHKaK7mQospSgkBDbEeKosRhL92JFyYQvaDaQVe7VnP0o7bnuIk1y3m1DEl65vE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=sB2rkaLY; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=c5DagRJ4; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=sB2rkaLY; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=c5DagRJ4; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="sB2rkaLY"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="c5DagRJ4"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="sB2rkaLY"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="c5DagRJ4" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 79DB53506E; Sun, 16 Jun 2024 07:34:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718523275; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9wtF003mZ1kzJMjnRxlwrBp4/g6dHssdJYK/M17rTu0=; b=sB2rkaLY04mCX6/SHUIvhmQuhYnpKf6fQSXRwffSD9nujLhHExvGalxrhf6UkcpYcBsliG WPk6guMevi8KWjfXE6EzfSVUhVnHW1zMtNmYeAoqIeehrX78D559hPnPtBIdw8AnO+NqEO 5yehNSlWGk8UfOgOI7eHFqeZ5ukLYiU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718523275; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9wtF003mZ1kzJMjnRxlwrBp4/g6dHssdJYK/M17rTu0=; b=c5DagRJ4wiSUQmdZgOx1ATTCIR3xJ1wBgWwSmgmr0YC0e8i9Q9wwm3oFKZZ2p17tk1TG9Z CKqGd6tlT7KQheAg== Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=sB2rkaLY; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=c5DagRJ4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718523275; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9wtF003mZ1kzJMjnRxlwrBp4/g6dHssdJYK/M17rTu0=; b=sB2rkaLY04mCX6/SHUIvhmQuhYnpKf6fQSXRwffSD9nujLhHExvGalxrhf6UkcpYcBsliG WPk6guMevi8KWjfXE6EzfSVUhVnHW1zMtNmYeAoqIeehrX78D559hPnPtBIdw8AnO+NqEO 5yehNSlWGk8UfOgOI7eHFqeZ5ukLYiU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718523275; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9wtF003mZ1kzJMjnRxlwrBp4/g6dHssdJYK/M17rTu0=; b=c5DagRJ4wiSUQmdZgOx1ATTCIR3xJ1wBgWwSmgmr0YC0e8i9Q9wwm3oFKZZ2p17tk1TG9Z CKqGd6tlT7KQheAg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 4481F13AB9; Sun, 16 Jun 2024 07:34:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id MIgLD4uVbmYVCwAAD6G6ig (envelope-from ); Sun, 16 Jun 2024 07:34:35 +0000 From: Takashi Iwai To: linux-sound@vger.kernel.org Cc: Paul Menzel , Mark Brown , Jaroslav Kysela , Takashi Sakamoto , linux-kselftest@vger.kernel.org Subject: [PATCH v3 4/6] kselftest/alsa: Fix validation of writes to volatile controls Date: Sun, 16 Jun 2024 09:34:45 +0200 Message-ID: <20240616073454.16512-5-tiwai@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240616073454.16512-1-tiwai@suse.de> References: <20240616073454.16512-1-tiwai@suse.de> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Queue-Id: 79DB53506E X-Spam-Score: -5.01 X-Spam-Level: X-Spam-Flag: NO X-Spamd-Result: default: False [-5.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; DWL_DNSWL_MED(-2.00)[suse.de:dkim]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCVD_COUNT_TWO(0.00)[2]; DKIM_TRACE(0.00)[suse.de:+]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns] X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org From: Mark Brown When validating writes to controls we check that whatever value we wrote actually appears in the control. For volatile controls we cannot assume that this will be the case, the value may be changed at any time including between our write and read. Handle this by moving the check for volatile controls that we currently do for events to a separate block and just verifying that whatever value we read is valid for the control. Signed-off-by: Mark Brown Link: https://lore.kernel.org/r/20240614-alsa-selftest-volatile-v1-1-3874f02964b1@kernel.org Signed-off-by: Takashi Iwai --- tools/testing/selftests/alsa/mixer-test.c | 45 +++++++++++++++-------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/tools/testing/selftests/alsa/mixer-test.c b/tools/testing/selftests/alsa/mixer-test.c index 1c04e5f638a0..dd74f8cc7ece 100644 --- a/tools/testing/selftests/alsa/mixer-test.c +++ b/tools/testing/selftests/alsa/mixer-test.c @@ -625,6 +625,21 @@ static int write_and_verify(struct ctl_data *ctl, return err; } + /* + * We can't verify any specific value for volatile controls + * but we should still check that whatever we read is a valid + * vale for the control. + */ + if (snd_ctl_elem_info_is_volatile(ctl->info)) { + if (!ctl_value_valid(ctl, read_val)) { + ksft_print_msg("Volatile control %s has invalid value\n", + ctl->name); + return -EINVAL; + } + + return 0; + } + /* * Check for an event if the value changed, or confirm that * there was none if it didn't. We rely on the kernel @@ -632,22 +647,20 @@ static int write_and_verify(struct ctl_data *ctl, * write, this is currently true, should that ever change this * will most likely break and need updating. */ - if (!snd_ctl_elem_info_is_volatile(ctl->info)) { - err = wait_for_event(ctl, 0); - if (snd_ctl_elem_value_compare(initial_val, read_val)) { - if (err < 1) { - ksft_print_msg("No event generated for %s\n", - ctl->name); - show_values(ctl, initial_val, read_val); - ctl->event_missing++; - } - } else { - if (err != 0) { - ksft_print_msg("Spurious event generated for %s\n", - ctl->name); - show_values(ctl, initial_val, read_val); - ctl->event_spurious++; - } + err = wait_for_event(ctl, 0); + if (snd_ctl_elem_value_compare(initial_val, read_val)) { + if (err < 1) { + ksft_print_msg("No event generated for %s\n", + ctl->name); + show_values(ctl, initial_val, read_val); + ctl->event_missing++; + } + } else { + if (err != 0) { + ksft_print_msg("Spurious event generated for %s\n", + ctl->name); + show_values(ctl, initial_val, read_val); + ctl->event_spurious++; } } From patchwork Sun Jun 16 07:34:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 13699455 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86B10178CF6; Sun, 16 Jun 2024 07:34:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718523279; cv=none; b=QI5xyor/KgRuG+0Rk0tGYJbv2ZUu7fyYzWU1VWpqsTsysO81rFO9BHS2XbBt95SXjrRDV8dzrov2bUncmhtPKXbVbSUbg9DFVbqdFr/FklJa7hh8e1pQmi94teR2VdfLnxJTAH1cx8hkVaFBuu4srabTSr2pvb7jHT3O6kYf3/Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718523279; c=relaxed/simple; bh=QeO5On+GiAI3IpqJmJUkztuf3OYNJlt8aK69Bq+/pkM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gdmmeZZaf4DikcnMHZfbPskkTvlvTuLqozMHUMUpYrFRj1SQCemcltmX05yY742IP4YAn2wsisZ1TeKC0RB1NhxbX1HZ7l1mKZey+99Gfv71tnx6mG/hzfapQVz1gsTus+wb5YwlGYBuBnJs2tPR4mQbHO0JWKgtIjWvZeXMNfE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=QEaqczgh; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=dQzRtRb2; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=QEaqczgh; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=dQzRtRb2; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="QEaqczgh"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="dQzRtRb2"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="QEaqczgh"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="dQzRtRb2" Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id B8B853506F; Sun, 16 Jun 2024 07:34:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718523275; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eyjBY4cnsbHVbl3obsodL0KpjflriZ5NqAnoc6bhaTg=; b=QEaqczghH2I5N70VeIhBehD6T5KW49DrK0xGuoUfJRSA3JdyVPGOzja2KvITvUXp1zwC+h SIJIX87av8Pk5MiHamo+nAJJY2aHAa3V+PdMoorxxjvGBRQTZCbhs1mchDAafYpTJT5QEZ +x0ODJ38hfstDh4fyyAPKjskfmCKwhw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718523275; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eyjBY4cnsbHVbl3obsodL0KpjflriZ5NqAnoc6bhaTg=; b=dQzRtRb2cUnNZIv60OsTUMBG5reg6kT2PKqFIw+ICyy82CwoskPWFbW+qbCjUbFlPYXe83 ELUzaoVDsBDnZ1CA== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718523275; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eyjBY4cnsbHVbl3obsodL0KpjflriZ5NqAnoc6bhaTg=; b=QEaqczghH2I5N70VeIhBehD6T5KW49DrK0xGuoUfJRSA3JdyVPGOzja2KvITvUXp1zwC+h SIJIX87av8Pk5MiHamo+nAJJY2aHAa3V+PdMoorxxjvGBRQTZCbhs1mchDAafYpTJT5QEZ +x0ODJ38hfstDh4fyyAPKjskfmCKwhw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718523275; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eyjBY4cnsbHVbl3obsodL0KpjflriZ5NqAnoc6bhaTg=; b=dQzRtRb2cUnNZIv60OsTUMBG5reg6kT2PKqFIw+ICyy82CwoskPWFbW+qbCjUbFlPYXe83 ELUzaoVDsBDnZ1CA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 80C8913ABC; Sun, 16 Jun 2024 07:34:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id IH8pHouVbmYVCwAAD6G6ig (envelope-from ); Sun, 16 Jun 2024 07:34:35 +0000 From: Takashi Iwai To: linux-sound@vger.kernel.org Cc: Paul Menzel , Mark Brown , Jaroslav Kysela , Takashi Sakamoto , linux-kselftest@vger.kernel.org Subject: [PATCH v3 5/6] ALSA: chmap: Mark Channel Map controls as volatile Date: Sun, 16 Jun 2024 09:34:46 +0200 Message-ID: <20240616073454.16512-6-tiwai@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240616073454.16512-1-tiwai@suse.de> References: <20240616073454.16512-1-tiwai@suse.de> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[99.99%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-Spam-Score: -2.80 X-Spam-Level: The values returned from Playback Channel Map and Capture Channel Map controls may vary dynamically depending on the corresponding PCM stream. Mark those as volatile to indicate the values are unstable and not suitable for testing. Note that we may change the driver to return -EINVAL, but this would bring other side effects, such as "alsactl restore" would start receiving unexpected errors. So we still keep returning 0 for those invalid inputs. Reported-by: Paul Menzel Closes: https://lore.kernel.org/r/1d44be36-9bb9-4d82-8953-5ae2a4f09405@molgen.mpg.de Reviewed-by: Jaroslav Kysela Signed-off-by: Takashi Iwai --- sound/core/pcm_lib.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/core/pcm_lib.c b/sound/core/pcm_lib.c index 6f73b3c2c205..071c67cbc479 100644 --- a/sound/core/pcm_lib.c +++ b/sound/core/pcm_lib.c @@ -2556,6 +2556,7 @@ int snd_pcm_add_chmap_ctls(struct snd_pcm *pcm, int stream, struct snd_kcontrol_new knew = { .iface = SNDRV_CTL_ELEM_IFACE_PCM, .access = SNDRV_CTL_ELEM_ACCESS_READ | + SNDRV_CTL_ELEM_ACCESS_VOLATILE | SNDRV_CTL_ELEM_ACCESS_TLV_READ | SNDRV_CTL_ELEM_ACCESS_TLV_CALLBACK, .info = pcm_chmap_ctl_info, From patchwork Sun Jun 16 07:34:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Takashi Iwai X-Patchwork-Id: 13699456 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D3C1A2941B; Sun, 16 Jun 2024 07:34:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718523279; cv=none; b=f5VO0WUwmHYG0TrPWJB4IDxOPYAzOaNI6ILY3VSqhBDfNBq3UEikUPlumtN6xiUT4bBCcrYumkj2GGH5TKAZqSh3QG4NLqO0ktg6zKpboGR7fW59vVd5tRHVPYsGOS0QnF4nO6vlkYB/sVKq7n3LoiwnHW6PQKR4FlrJoTFnNuA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718523279; c=relaxed/simple; bh=SwaColnG8+NA5mzJiCzY2KsB18wTd7EwWwGioyjcJNI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OJj2TeeJGUWnwAsUTcI3k/oi7Q69mJ/S2H6qTZhiAyH3EibdKFN8+DBoUn3lz1jran/s0xQsh7jH5xxGZDncIftmbkBmMFLK6c9Qfu2lbteYIiPzD/kVmD+P73++vnNqtbi91/un9fRHFCGDN8pwt2oxNfytIlikIJTOhabXpg8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=ShBVukf/; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=N1PLYg+q; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=ShBVukf/; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=N1PLYg+q; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="ShBVukf/"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="N1PLYg+q"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="ShBVukf/"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="N1PLYg+q" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 02E445CCBF; Sun, 16 Jun 2024 07:34:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718523276; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kvtarVlDPFvjlhozhdO7C2Qw7XUn6ZldtP0itrE1uEQ=; b=ShBVukf/DrtFSuQnpqxwp5hqAkta2efl2sN56Oa6sb6CWAouyeWf1qcD5XnT/5zY4IRPxV IMFmjNN3OuvACtFNLtrLXTsVLgKsv+ATZJV/yT9JDien3DemWlOXLbjVgTzBhzBu3/WV5h 9lLoEM0Zb1GmHPlzqX2c5VTedtqmykk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718523276; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kvtarVlDPFvjlhozhdO7C2Qw7XUn6ZldtP0itrE1uEQ=; b=N1PLYg+qpL8XiaH7Pyv+dIsEO3H/Acoy8TrkUyzvrRxwyVm3e7UFbt0WBWCD8MUwIlzC4H 05ooVgelFruP3tAQ== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="ShBVukf/"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=N1PLYg+q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1718523276; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kvtarVlDPFvjlhozhdO7C2Qw7XUn6ZldtP0itrE1uEQ=; b=ShBVukf/DrtFSuQnpqxwp5hqAkta2efl2sN56Oa6sb6CWAouyeWf1qcD5XnT/5zY4IRPxV IMFmjNN3OuvACtFNLtrLXTsVLgKsv+ATZJV/yT9JDien3DemWlOXLbjVgTzBhzBu3/WV5h 9lLoEM0Zb1GmHPlzqX2c5VTedtqmykk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1718523276; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kvtarVlDPFvjlhozhdO7C2Qw7XUn6ZldtP0itrE1uEQ=; b=N1PLYg+qpL8XiaH7Pyv+dIsEO3H/Acoy8TrkUyzvrRxwyVm3e7UFbt0WBWCD8MUwIlzC4H 05ooVgelFruP3tAQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id BEF4E13AB9; Sun, 16 Jun 2024 07:34:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id mI9GLYuVbmYVCwAAD6G6ig (envelope-from ); Sun, 16 Jun 2024 07:34:35 +0000 From: Takashi Iwai To: linux-sound@vger.kernel.org Cc: Paul Menzel , Mark Brown , Jaroslav Kysela , Takashi Sakamoto , linux-kselftest@vger.kernel.org Subject: [PATCH v3 6/6] ALSA: hda: Add input value sanity checks to HDMI channel map controls Date: Sun, 16 Jun 2024 09:34:47 +0200 Message-ID: <20240616073454.16512-7-tiwai@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240616073454.16512-1-tiwai@suse.de> References: <20240616073454.16512-1-tiwai@suse.de> Precedence: bulk X-Mailing-List: linux-kselftest@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Rspamd-Queue-Id: 02E445CCBF X-Spam-Score: -5.01 X-Spam-Level: X-Spam-Flag: NO X-Spamd-Result: default: False [-5.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; DWL_DNSWL_MED(-2.00)[suse.de:dkim]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_BLOCKED(0.00)[rspamd.com]; TO_DN_SOME(0.00)[]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCVD_COUNT_TWO(0.00)[2]; DKIM_TRACE(0.00)[suse.de:+]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns] X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org 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 --- 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 5d8e1d944b0a..7b276047f85a 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 */