From patchwork Thu Oct 20 20:46:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej S. Szmigiero" X-Patchwork-Id: 6393 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp316043wrr; Thu, 20 Oct 2022 13:48:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7/3Devuknf910Fw4Jh6nT51v/vn9Ft8zFSXveQVBMi42/QRCBHSTbDP0yngUIy7Z+CXc4k X-Received: by 2002:a17:907:6d27:b0:78d:46f6:c59e with SMTP id sa39-20020a1709076d2700b0078d46f6c59emr12349663ejc.30.1666298911529; Thu, 20 Oct 2022 13:48:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666298911; cv=none; d=google.com; s=arc-20160816; b=vfml9B+Gf+0bXlb6E10mqPe44XX9Y0PEXIbvzXJDbQ6t+7pfcMXDFRa6e0bkusBvOi 3md6E1pzECisfhwMu8V/NLT3wnVwgnR9KEbMeB/SHl5p18Tsz6ssKx9zYcIzcZcOp2Y1 JfAkY1n0cBwTSFHnc/48eWFmtZt5wc05sIVG6HpZfqdwAxBFMWOrBLKEn6SMtGNRp1cI HR+3sxE7HwXQ5V9gdOVB086v0nvKeasls7rbLWBctoBhNzfiFQg/guPE8NNPFrJ7uPCZ CSrTHGbVQOKI2LGRRlpbefvOHQXPCKTopDeZ9MJQIkJxNfBVPVhNJE2gqfN0JZXVzAAm NUGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=Dtd57xMd2zyxu82Sf0qwTa41GDz4tMf3CL4dxGtITlY=; b=iA72Z0NT67+zStG9mWCKlYZZd00jecyHyifaG1xGtyuwttBLFxhTbTmrg32aA71con xtZYvTpXstE6+7+uCvU/3y73HxOcenR0ZIY2a+T0bF7JQ8ckmxWa3qKfaZON4LuWivQR /s2Lj5+lv9mTX1YIGU6+ABohGxP279Qg9I5Fd2CrZyV1s8AUgMH8OYF4vR4z/R/d86ki /1HJ7Zv9w3gwkKG40m2e9rEYqCV8lPkU5qjB/EolGWpfr82qqGU3OOz37P7xWwNRqdp/ F0Dl1marxcXOK/nhGWrCFT0k20N2/L7xg831t+VRNVWBQ+Sl1YPDWYhOV68O0ROukXAK CPlQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bx20-20020a170906a1d400b0078d40f7ef1fsi16143432ejb.330.2022.10.20.13.48.07; Thu, 20 Oct 2022 13:48:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229768AbiJTUri (ORCPT + 99 others); Thu, 20 Oct 2022 16:47:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46376 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229658AbiJTUrd (ORCPT ); Thu, 20 Oct 2022 16:47:33 -0400 Received: from vps-vb.mhejs.net (vps-vb.mhejs.net [37.28.154.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01835170448 for ; Thu, 20 Oct 2022 13:47:20 -0700 (PDT) Received: from MUA by vps-vb.mhejs.net with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1olcR3-0007Ue-TS; Thu, 20 Oct 2022 22:46:37 +0200 From: "Maciej S. Szmigiero" To: Jaroslav Kysela , Takashi Iwai Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/6] ALSA: control: add snd_ctl_rename() Date: Thu, 20 Oct 2022 22:46:21 +0200 Message-Id: <4170b71117ea81357a4f7eb8410f7cde20836c70.1666296963.git.maciej.szmigiero@oracle.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747241047661116840?= X-GMAIL-MSGID: =?utf-8?q?1747241047661116840?= From: "Maciej S. Szmigiero" Add a snd_ctl_rename() function that takes care of updating the control hash entries for callers that already have the relevant struct snd_kcontrol at hand and hold the control write lock (or simply haven't registered the card yet). Fixes: c27e1efb61c5 ("ALSA: control: Use xarray for faster lookups") Cc: stable@vger.kernel.org Signed-off-by: Maciej S. Szmigiero --- include/sound/control.h | 1 + sound/core/control.c | 23 +++++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/include/sound/control.h b/include/sound/control.h index eae443ba79ba5..cc3dcc6cfb0f2 100644 --- a/include/sound/control.h +++ b/include/sound/control.h @@ -138,6 +138,7 @@ int snd_ctl_remove(struct snd_card * card, struct snd_kcontrol * kcontrol); int snd_ctl_replace(struct snd_card *card, struct snd_kcontrol *kcontrol, bool add_on_replace); int snd_ctl_remove_id(struct snd_card * card, struct snd_ctl_elem_id *id); int snd_ctl_rename_id(struct snd_card * card, struct snd_ctl_elem_id *src_id, struct snd_ctl_elem_id *dst_id); +void snd_ctl_rename(struct snd_card *card, struct snd_kcontrol *kctl, const char *name); int snd_ctl_activate_id(struct snd_card *card, struct snd_ctl_elem_id *id, int active); struct snd_kcontrol *snd_ctl_find_numid(struct snd_card * card, unsigned int numid); struct snd_kcontrol *snd_ctl_find_id(struct snd_card * card, struct snd_ctl_elem_id *id); diff --git a/sound/core/control.c b/sound/core/control.c index a7271927d875f..50e7ba66f1876 100644 --- a/sound/core/control.c +++ b/sound/core/control.c @@ -753,6 +753,29 @@ int snd_ctl_rename_id(struct snd_card *card, struct snd_ctl_elem_id *src_id, } EXPORT_SYMBOL(snd_ctl_rename_id); +/** + * snd_ctl_rename - rename the control on the card + * @card: the card instance + * @kctl: the control to rename + * @name: the new name + * + * Renames the specified control on the card to the new name. + * + * Make sure to take the control write lock - down_write(&card->controls_rwsem). + */ +void snd_ctl_rename(struct snd_card *card, struct snd_kcontrol *kctl, + const char *name) +{ + remove_hash_entries(card, kctl); + + if (strscpy(kctl->id.name, name, sizeof(kctl->id.name)) < 0) + pr_warn("ALSA: Renamed control new name '%s' truncated to '%s'\n", + name, kctl->id.name); + + add_hash_entries(card, kctl); +} +EXPORT_SYMBOL(snd_ctl_rename); + #ifndef CONFIG_SND_CTL_FAST_LOOKUP static struct snd_kcontrol * snd_ctl_find_numid_slow(struct snd_card *card, unsigned int numid) From patchwork Thu Oct 20 20:46:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej S. Szmigiero" X-Patchwork-Id: 6392 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp315989wrr; Thu, 20 Oct 2022 13:48:21 -0700 (PDT) X-Google-Smtp-Source: AMsMyM49L/m/fNMkBTpw4qAy+1i2PeSZ6o5v+dwzRn12xaWnXsYRyiX0mf50/1wgmSoIqnroqdZU X-Received: by 2002:aa7:c054:0:b0:453:98c6:f6c4 with SMTP id k20-20020aa7c054000000b0045398c6f6c4mr13863681edo.2.1666298901394; Thu, 20 Oct 2022 13:48:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666298901; cv=none; d=google.com; s=arc-20160816; b=W2/EGhCVT7z0LSPQEHeC/vE11SwNJs7lS+bQZLCalp7bBPYGWZs3l0ChyNiHKXcO7g nnRym6JRzoO8/df/4PQYsOaryXp0F+cgypvPM5lOQL9mzXprsn10rUGPs89koKq1TgeR SqkXfAik5Z3zPCKlS189R0rpdEYmqAWV8iInrIJq4ANqsKOMS74gVam1BAc03R1CKMoW m0t2ha69QCzIs7Epg60dISL+nqn2xiIYA8At8fEgsPFAH022tkWQRd05jFD1e+DOipRD pCQxzFlPzjgwjlWXPrbD6QPV+BrtLDBuPoTI14x+OnX0VI9mw42FnPvobk2UFaSZIimx RXVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=3fCsTwB7TQ9uC8UPZ+BwI1sCJTZmBJ7NrtHuUkE2UP0=; b=y5Vi9AJfMIDpefQ5fxxLeqd47+P7+C7PHi5NipXTAupBS/qbCe6nfUTy3UR4Ue24/r NFBE/FERD9YSPKXRyFk8JaoEzifx6g7RjylJ+2pzyaHLbWaTJ6sYltWy2/rfrWh30/4k 8k439fu42YuNy0nfVI3cZ3BRLtZVyiXiFckMlaXn2MCHHoQs1PclAfZQk+U9GmE0Yc1i w+7iXh1klf8ISQhgsNp/LPN8p0M7Qn1lomQE1f96FMQ83rwWtsXI7kNRLIiqIhtdoe6j pmN5lD1h9DYb2YJMBSC/KWmY3OH/FEuF1OLia1eJCpvfaUK/B7aLDuNq1m26/JsJwvmY jaow== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dr8-20020a170907720800b006feb76dbd51si18709545ejc.289.2022.10.20.13.47.57; Thu, 20 Oct 2022 13:48:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229494AbiJTUrf (ORCPT + 99 others); Thu, 20 Oct 2022 16:47:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229685AbiJTUrd (ORCPT ); Thu, 20 Oct 2022 16:47:33 -0400 Received: from vps-vb.mhejs.net (vps-vb.mhejs.net [37.28.154.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B91597B59E for ; Thu, 20 Oct 2022 13:47:24 -0700 (PDT) Received: from MUA by vps-vb.mhejs.net with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1olcR9-0007Ur-7p; Thu, 20 Oct 2022 22:46:43 +0200 From: "Maciej S. Szmigiero" To: Jaroslav Kysela , Takashi Iwai Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/6] ALSA: usb-audio: Use snd_ctl_rename() to rename a control Date: Thu, 20 Oct 2022 22:46:22 +0200 Message-Id: <723877882e3a56bb42a2a2214cfc85f347d36e19.1666296963.git.maciej.szmigiero@oracle.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747241036493679021?= X-GMAIL-MSGID: =?utf-8?q?1747241036493679021?= From: "Maciej S. Szmigiero" With the recent addition of hashed controls lookup it's not enough to just update the control name field, the hash entries for the modified control have to be updated too. snd_ctl_rename() takes care of that, so use it instead of directly modifying the control name. Fixes: c27e1efb61c5 ("ALSA: control: Use xarray for faster lookups") Cc: stable@vger.kernel.org Signed-off-by: Maciej S. Szmigiero --- sound/usb/mixer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index a5641956ef102..9105ec623120a 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c @@ -1631,7 +1631,7 @@ static void check_no_speaker_on_headset(struct snd_kcontrol *kctl, if (!found) return; - strscpy(kctl->id.name, "Headphone", sizeof(kctl->id.name)); + snd_ctl_rename(card, kctl, "Headphone"); } static const struct usb_feature_control_info *get_feature_control_info(int control) From patchwork Thu Oct 20 20:46:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej S. Szmigiero" X-Patchwork-Id: 6394 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp316134wrr; Thu, 20 Oct 2022 13:48:50 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4yPvAha6QmIo0LoLAkEC8kGIf6rUuUGgVvXebb48tlkDcQMl3BEYz2S/FZhLfSXvZaJFls X-Received: by 2002:a17:906:5daa:b0:791:8933:f9f0 with SMTP id n10-20020a1709065daa00b007918933f9f0mr12497516ejv.335.1666298929821; Thu, 20 Oct 2022 13:48:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666298929; cv=none; d=google.com; s=arc-20160816; b=BMe8H9Un8c7wWzIKCleUUa+DVo3m9NqL26VEbNauuG7AbvGv6IO1k6os+H+kS23Sau dyieBgnhjxNDggc/dGn8kQ0gxJWOqMcrbAXti4J/VOfe7jxiT4RefwAs5QpkWsbaSenu hVBIPIA7CP60+C7VnyOAiIw2w1tarh2x/xGVIRtZGHGi5lW3Ijez+Nkltdo+SdGaF8M2 6z0uG3uKtMxQVy4Qw5z1jlDoFy/+fpIojxtVqraBKqW8vW1yG9ge0HiyIV5gI9LH1xAf iUkQkujdSCe6KeVMF2w/iJJio/gP/Q5VJlkfSJp3tdhL2EMBv75gfIicPbeq287JDSZ0 X8iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=tvMAfDZYwsEuZciMyTG0kmHNr3e12NZWFmA6tvxfFeQ=; b=NGnqDbzZotGkNs12AK0p80bbzXrcjjdvQGz8e2JT+mMZtPGxTjMAfwnRvWsTq+Tx1U NHq1VRimKS9SzdiLXdXZTpIt95HYeEoL3a/ElLZKTVmmZJ1ebaft+/fCLNGo9/VpzMzE 3IJPjkGzeMWvkvhyZ928c362YR0kiNzdQ58hEMs41UwvuSUjmF7EECee06XassospAzF voJxQsjmcdO2TLO7fFE2Vp6JDE7jjZy54Iy1eKDd9CASue/4irWo4PC1pVMr8m7G9vh1 HY++hgTzRcgFqvcPMAtgarQz5aF3G4gCiQUCrd7ttJacJbkSNQ2j07Aj+Sq+u37iTS5G oDkQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id q7-20020a1709060e4700b0078e176ef65csi15560063eji.723.2022.10.20.13.48.26; Thu, 20 Oct 2022 13:48:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229917AbiJTUrr (ORCPT + 99 others); Thu, 20 Oct 2022 16:47:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46556 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229788AbiJTUri (ORCPT ); Thu, 20 Oct 2022 16:47:38 -0400 Received: from vps-vb.mhejs.net (vps-vb.mhejs.net [37.28.154.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABF5521F96D for ; Thu, 20 Oct 2022 13:47:26 -0700 (PDT) Received: from MUA by vps-vb.mhejs.net with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1olcRE-0007V3-Jm; Thu, 20 Oct 2022 22:46:48 +0200 From: "Maciej S. Szmigiero" To: Jaroslav Kysela , Takashi Iwai Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/6] ALSA: hda/realtek: Use snd_ctl_rename() to rename a control Date: Thu, 20 Oct 2022 22:46:23 +0200 Message-Id: <37496bd80f91f373268148f877fd735917d97287.1666296963.git.maciej.szmigiero@oracle.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747241066577681131?= X-GMAIL-MSGID: =?utf-8?q?1747241066577681131?= From: "Maciej S. Szmigiero" With the recent addition of hashed controls lookup it's not enough to just update the control name field, the hash entries for the modified control have to be updated too. snd_ctl_rename() takes care of that, so use it instead of directly modifying the control name. Fixes: c27e1efb61c5 ("ALSA: control: Use xarray for faster lookups") Cc: stable@vger.kernel.org Signed-off-by: Maciej S. Szmigiero --- sound/pci/hda/patch_realtek.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/hda/patch_realtek.c b/sound/pci/hda/patch_realtek.c index 79acd2a2caf20..9945861f02efa 100644 --- a/sound/pci/hda/patch_realtek.c +++ b/sound/pci/hda/patch_realtek.c @@ -2142,7 +2142,7 @@ static void rename_ctl(struct hda_codec *codec, const char *oldname, kctl = snd_hda_find_mixer_ctl(codec, oldname); if (kctl) - strcpy(kctl->id.name, newname); + snd_ctl_rename(codec->card, kctl, newname); } static void alc1220_fixup_gb_dual_codecs(struct hda_codec *codec, From patchwork Thu Oct 20 20:46:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej S. Szmigiero" X-Patchwork-Id: 6395 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp316205wrr; Thu, 20 Oct 2022 13:49:02 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6tXa13InEz1Lyu1EHeFKL7gfDkShYT2QQSnGfWiKah1Dno4eoHyhevstuetK1rClMrzq8E X-Received: by 2002:a17:907:2672:b0:781:dc01:6c5a with SMTP id ci18-20020a170907267200b00781dc016c5amr13014696ejc.191.1666298942054; Thu, 20 Oct 2022 13:49:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666298942; cv=none; d=google.com; s=arc-20160816; b=JHzFRTTY14yqVmw1/7QNouOduPVa/hZ6JdKysSHiTPP0Vytmjh8tYWMw3JjZSUXy8V lbbG+7OY2lCY0fRFrh0F5MaHQ2NaKw8NxI6YW74kN27eiCTyYSw0KPn/omIs8mvtCzTI N2MhIHOY5q+guiOxaZcte41so2sQYIXtsMEfcDEvb+7yg46xp0gYeaAKEBabuLszOpVJ IFzoQW/5tcgUox3tcRne+NtSfhvA91EICqedPBDat72kC9ne/MJ9YIsitsKpfpI2K4Vb +qPh9Z5AoEMU/O3DOWPaqjK76WI915Foc6I4ljllq/hmSafl2vBd3mpigI1icZTEAN3R NuLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=hnyG35U0aq3+xPn0XjULIJimyqgTlJsM7cpIx785M1o=; b=D+Ps+eFYR1aMS9dkelyuiIEwIZM932VMernxY9ZgMUpOOUHsgkDiKmNsWO9Go4W6g8 BP7siF64fMwQl9Ru+u/7ges78dYukINyd540iJ6qxHMkl8qmmWiCbe1TIcOQl6IjKzRJ Ly1k7PCZzomBJOHv4i1S3rWgBH05JBPvvAHAEyRmeBG5lwe+Gk/27ZVGGNYB8D8t64nF DNlrKt5jK5Gqo+MlP3hsOfH7aD6wSu5bntvx0cdwurYyeQwYkdad9PDSChzau7O2oB9c FfQOLViaGA+crll3TShxerZ6wekVYUEcwh9MogBALk7/5JeOhETdilmqMrbockGNVIV4 TphQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sd41-20020a1709076e2900b0078c2c22d6cesi18896926ejc.70.2022.10.20.13.48.37; Thu, 20 Oct 2022 13:49:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229635AbiJTUrw (ORCPT + 99 others); Thu, 20 Oct 2022 16:47:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46684 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229874AbiJTUrl (ORCPT ); Thu, 20 Oct 2022 16:47:41 -0400 Received: from vps-vb.mhejs.net (vps-vb.mhejs.net [37.28.154.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0CBDB21A848 for ; Thu, 20 Oct 2022 13:47:29 -0700 (PDT) Received: from MUA by vps-vb.mhejs.net with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1olcRJ-0007VG-Ty; Thu, 20 Oct 2022 22:46:53 +0200 From: "Maciej S. Szmigiero" To: Jaroslav Kysela , Takashi Iwai Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/6] ALSA: emu10k1: Use snd_ctl_rename() to rename a control Date: Thu, 20 Oct 2022 22:46:24 +0200 Message-Id: <38b19f019f95ee78a6e4e59d39afb9e2c3379413.1666296963.git.maciej.szmigiero@oracle.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747241079632670095?= X-GMAIL-MSGID: =?utf-8?q?1747241079632670095?= From: "Maciej S. Szmigiero" With the recent addition of hashed controls lookup it's not enough to just update the control name field, the hash entries for the modified control have to be updated too. snd_ctl_rename() takes care of that, so use it instead of directly modifying the control name. Fixes: c27e1efb61c5 ("ALSA: control: Use xarray for faster lookups") Cc: stable@vger.kernel.org Signed-off-by: Maciej S. Szmigiero --- sound/pci/emu10k1/emumixer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/emu10k1/emumixer.c b/sound/pci/emu10k1/emumixer.c index e9c0fe3b84461..3c115f8ab96c0 100644 --- a/sound/pci/emu10k1/emumixer.c +++ b/sound/pci/emu10k1/emumixer.c @@ -1767,7 +1767,7 @@ static int rename_ctl(struct snd_card *card, const char *src, const char *dst) { struct snd_kcontrol *kctl = ctl_find(card, src); if (kctl) { - strcpy(kctl->id.name, dst); + snd_ctl_rename(card, kctl, dst); return 0; } return -ENOENT; From patchwork Thu Oct 20 20:46:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej S. Szmigiero" X-Patchwork-Id: 6396 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp316442wrr; Thu, 20 Oct 2022 13:49:42 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4lZzSFIimKD3xkwloHQO4ojpgiBpbt/FcFSLPV5H/1+OSu3siHCn31Sg9BDTqcF9Rh0fUZ X-Received: by 2002:a05:6402:370c:b0:453:9fab:1b53 with SMTP id ek12-20020a056402370c00b004539fab1b53mr14277721edb.28.1666298982066; Thu, 20 Oct 2022 13:49:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666298982; cv=none; d=google.com; s=arc-20160816; b=EsNIz33wfpIOMcDK6SN7Vv2LIjStBO93kv1R+g4xCEgqu1ahTdRT0yq8/BmsRRDjDf 55oc/cuWxhjpUPGYZ3ALgmwiKc2rbfVOCVlG/g6TjsyZxwoCaMZaqgSqRYfuV5/AYOJf oOJqjDCy2sVF+sZ15ivBXR6z7cGVQD8UrEu0ZCTX62/wa1RTRuMNGT1BgxMnLjOQq3iy QX7TK2qjXh4LknYlKujoDEMLOUI6/tA4QAO5Gn89LFi+JfbI+Gimi9MqfLqZwNAzFdHH mAVpRKsjy0T7AKYeGuZ/3Z10Zh2R7bWe/jABPBOntu9aMWmiHiIa51SwIR1COEIChI1Y L5Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=VTp+kTu8Dsz+y7sHpJtKzqGBm65dsd21gc11j8E9Gig=; b=FoBBsE4DhB7g2dITZ/Hxg7Rw13wSZ42g//Vjv7ZCderUj1advgV0U40VZnbt9pkcWM kW4+JEj9Rdjm+Ew+/mwV0DPuOBEJn1rHK6vAVb6cjstwX7Jh0T0wY0/ybcODnzsE6A4Z SmPvkRo3rrMpUzERuMQkz1d9VxAx5mxwDeNdiweLZz1l/zkpAzUz1y8RLa7EQrKpU+eB qVp4Ib/WJzgvZg7uMuSQwUTjLM4pMOwAlTh525PBrmyLj1ce3pPvHJKaQyu4LxR8fqdx bS/FA7OB/KLE4I9bgsJ7UvRYQRrOWPWB6t7t3QM8jFqKOqC3Kp3lmD69rxQCLxKsY0KG oqBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lt4-20020a170906fa8400b0078d8b6976eesi15190976ejb.140.2022.10.20.13.49.17; Thu, 20 Oct 2022 13:49:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229972AbiJTUr4 (ORCPT + 99 others); Thu, 20 Oct 2022 16:47:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229890AbiJTUro (ORCPT ); Thu, 20 Oct 2022 16:47:44 -0400 Received: from vps-vb.mhejs.net (vps-vb.mhejs.net [37.28.154.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 586335B730 for ; Thu, 20 Oct 2022 13:47:31 -0700 (PDT) Received: from MUA by vps-vb.mhejs.net with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1olcRP-0007VS-7d; Thu, 20 Oct 2022 22:46:59 +0200 From: "Maciej S. Szmigiero" To: Jaroslav Kysela , Takashi Iwai Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/6] ALSA: ca0106: Use snd_ctl_rename() to rename a control Date: Thu, 20 Oct 2022 22:46:25 +0200 Message-Id: X-Mailer: git-send-email 2.37.3 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747241121331998921?= X-GMAIL-MSGID: =?utf-8?q?1747241121331998921?= From: "Maciej S. Szmigiero" With the recent addition of hashed controls lookup it's not enough to just update the control name field, the hash entries for the modified control have to be updated too. snd_ctl_rename() takes care of that, so use it instead of directly modifying the control name. Fixes: c27e1efb61c5 ("ALSA: control: Use xarray for faster lookups") Cc: stable@vger.kernel.org Signed-off-by: Maciej S. Szmigiero --- sound/pci/ca0106/ca0106_mixer.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c index 05f56015ddd87..f6381c098d4f6 100644 --- a/sound/pci/ca0106/ca0106_mixer.c +++ b/sound/pci/ca0106/ca0106_mixer.c @@ -720,7 +720,7 @@ static int rename_ctl(struct snd_card *card, const char *src, const char *dst) { struct snd_kcontrol *kctl = ctl_find(card, src); if (kctl) { - strcpy(kctl->id.name, dst); + snd_ctl_rename(card, kctl, dst); return 0; } return -ENOENT; From patchwork Thu Oct 20 20:46:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Maciej S. Szmigiero" X-Patchwork-Id: 6398 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp319300wrr; Thu, 20 Oct 2022 13:58:30 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7EpN1wROeRhdlxV/AgByeUD9eId1W2SX0ogIWOn1bZs52XtUiHQjsjEqs6qChq9PhzR4KB X-Received: by 2002:a05:6402:3806:b0:450:bad8:8cd5 with SMTP id es6-20020a056402380600b00450bad88cd5mr14412239edb.305.1666299510634; Thu, 20 Oct 2022 13:58:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666299510; cv=none; d=google.com; s=arc-20160816; b=dtEgdB4tw1odxjB9m9pGUskVFfmvOHqbnc1lHkCgX+R0DrEsL70k4zWxRmuIKbgaQh Rg39zm8mqFV/MqRpVmmia7/f5Ys2IFR9fiIrrqTRMwBxg6GOlV8IYmGSZ7mRmEZX+2H1 a1loevb/sCW5xlMVnTHgQY+wS9YOQP7+wRTx2OCeuSVzizvjbUfXYa1yj653SvioUJU/ yft1Sr04fNOqfyTC1aiw8l4cqSuPQsv+kwJXvn0I88EOC7Vtx9C+4yfwD4/JPqlAqtw7 ti4KcWDKK5A/orSwqFD9zDNPb4ytAQ0jr+qK/YrNRG8J8Cbs1W1CXA6ItRAg6zd8Tp/g GtnQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=verngwKXvaugahFxwVn6wZIK3S9n5X4DmomiiARplns=; b=so6XT+VFrwe65q4NG7oGeAk9GK6Edd6SMvqjatK97CCudnatm0cK0QSui/hRkIrEpv 3T8Xu7Ym/FGHIkpy0uvF8udnLy0qIGJ5fv/StO4Lx5n05dTn6k0HN7sLEfLzEWkdADUs 0UlFNjDur0zYtfN7xMys2B4ucAkLqEciIU0z4Ch6uR8Foepmq5IZ8LR259hIsyqcxbJ4 yq6zZD42oKN63WDOvt7EVyb+wWV7XdgpaCKJPhjQfahJC6q+lRVyom54cNCIlZH6ffqk Rco4JEbV+IGDDxviQ09p1wkKjue45n2EUsJnIDPdpioT5hkBRya5EHAo1DEaxgyufU/P yDRA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h7-20020aa7c947000000b00459400b7ae0si15353710edt.613.2022.10.20.13.58.05; Thu, 20 Oct 2022 13:58:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229720AbiJTUsB (ORCPT + 99 others); Thu, 20 Oct 2022 16:48:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229808AbiJTUrx (ORCPT ); Thu, 20 Oct 2022 16:47:53 -0400 Received: from vps-vb.mhejs.net (vps-vb.mhejs.net [37.28.154.113]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBD6F1B2338 for ; Thu, 20 Oct 2022 13:47:36 -0700 (PDT) Received: from MUA by vps-vb.mhejs.net with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1olcRU-0007Vc-JN; Thu, 20 Oct 2022 22:47:04 +0200 From: "Maciej S. Szmigiero" To: Jaroslav Kysela , Takashi Iwai Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/6] ALSA: ac97: Use snd_ctl_rename() to rename a control Date: Thu, 20 Oct 2022 22:46:26 +0200 Message-Id: X-Mailer: git-send-email 2.37.3 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747241675371631235?= X-GMAIL-MSGID: =?utf-8?q?1747241675371631235?= From: "Maciej S. Szmigiero" With the recent addition of hashed controls lookup it's not enough to just update the control name field, the hash entries for the modified control have to be updated too. snd_ctl_rename() takes care of that, so use it instead of directly modifying the control name. While we are at it, check also that the new control name doesn't accidentally overwrite the available buffer space. Fixes: c27e1efb61c5 ("ALSA: control: Use xarray for faster lookups") Cc: stable@vger.kernel.org Signed-off-by: Maciej S. Szmigiero --- sound/pci/ac97/ac97_codec.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/sound/pci/ac97/ac97_codec.c b/sound/pci/ac97/ac97_codec.c index ceead55f13ab1..ff685321f1a11 100644 --- a/sound/pci/ac97/ac97_codec.c +++ b/sound/pci/ac97/ac97_codec.c @@ -2656,11 +2656,18 @@ EXPORT_SYMBOL(snd_ac97_resume); */ static void set_ctl_name(char *dst, const char *src, const char *suffix) { - if (suffix) - sprintf(dst, "%s %s", src, suffix); - else - strcpy(dst, src); -} + const size_t msize = SNDRV_CTL_ELEM_ID_NAME_MAXLEN; + + if (suffix) { + if (snprintf(dst, msize, "%s %s", src, suffix) >= msize) + pr_warn("ALSA: AC97 control name '%s %s' truncated to '%s'\n", + src, suffix, dst); + } else { + if (strscpy(dst, src, msize) < 0) + pr_warn("ALSA: AC97 control name '%s' truncated to '%s'\n", + src, dst); + } +} /* remove the control with the given name and optional suffix */ static int snd_ac97_remove_ctl(struct snd_ac97 *ac97, const char *name, @@ -2687,8 +2694,11 @@ static int snd_ac97_rename_ctl(struct snd_ac97 *ac97, const char *src, const char *dst, const char *suffix) { struct snd_kcontrol *kctl = ctl_find(ac97, src, suffix); + char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; + if (kctl) { - set_ctl_name(kctl->id.name, dst, suffix); + set_ctl_name(name, dst, suffix); + snd_ctl_rename(ac97->bus->card, kctl, name); return 0; } return -ENOENT; @@ -2707,11 +2717,17 @@ static int snd_ac97_swap_ctl(struct snd_ac97 *ac97, const char *s1, const char *s2, const char *suffix) { struct snd_kcontrol *kctl1, *kctl2; + char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; + kctl1 = ctl_find(ac97, s1, suffix); kctl2 = ctl_find(ac97, s2, suffix); if (kctl1 && kctl2) { - set_ctl_name(kctl1->id.name, s2, suffix); - set_ctl_name(kctl2->id.name, s1, suffix); + set_ctl_name(name, s2, suffix); + snd_ctl_rename(ac97->bus->card, kctl1, name); + + set_ctl_name(name, s1, suffix); + snd_ctl_rename(ac97->bus->card, kctl2, name); + return 0; } return -ENOENT;