Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp291512pxm; Wed, 2 Mar 2022 15:36:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJyOkZg1wv3WlrwlHwqNcVRlTIKCvH/MSP5dwlplpo7ZfKXoC6Rl2TAzDJuUEDrHsqPKJUtK X-Received: by 2002:a05:6a00:1a04:b0:4e1:294:e1e5 with SMTP id g4-20020a056a001a0400b004e10294e1e5mr34921446pfv.51.1646264167480; Wed, 02 Mar 2022 15:36:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646264167; cv=none; d=google.com; s=arc-20160816; b=DN5L1rrM2UmrFv869ZDlGwbr4kNkKgT8yR+KoBoToJqSLKO7KTd4nzb+Pb5OtAvrRO ++h/ShMF0NbEwMp8CihvDPFpO0+ost5Izdaes/DytaZzsH5ohQDj6PwXZOQAHEhV3yt2 5fL0VPyLt1JwevC8vdaP/b3CEfl6iEb2ze2VM/rIj5simxU2pxYjRgQ6anTkpVuR/uIu A2Nvnn8ad6L+YjB6z8sEkHSJHiY+G3G5/sy+TjIAkeuulqCXAeEuo1VqFLddJC/iaRyk CwNEwR1jnqMT1wf6OsL5/e1E8Qof4HwIa7JQ0YMpK4jo44WKKkyP4EErZ5C5uHRG0glq XM6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:feedback-id:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from; bh=MiETbfcOAK7MYGNC+NRsm2j1lwhv3k+OD8ZBDPGjFd0=; b=NsV8PcEjhu64rtsA9Fvh2hiRGBWP1ONqmvIGGftXlYsJINjAdAIPpBauDnb4wb5nJj 0mEuyAj+c1StFbOgbImGSQa6myPOgLSVJL8kAS34yBsFcaoSXq2gQrWhSP7iNIyKpAjD UUkGuFnhurtsTsvOdqx+QoENNW3WwuBzek6EL54CvbRnb8WJOkJQOuHiwy0fX8otgo8W UecruvJTZni5d8WaN3H95IuVi46bE7WjtqhT0OOb8CJJ/09rWOuSl3hvktIEdttMsY/6 aN0swEWtMGuIeqbtZh+XKfJBkyduafVdBmkBztiGPx4wcMWLrmEOPLMrU9xz9zgPoac5 EIrQ== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id e24-20020a656898000000b00379e01b510fsi442324pgt.145.2022.03.02.15.36.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Mar 2022 15:36:07 -0800 (PST) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email [IPv6:2620:137:e000::1:20]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0B9AD3BA66; Wed, 2 Mar 2022 15:04:06 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240539AbiCBJpG (ORCPT + 99 others); Wed, 2 Mar 2022 04:45:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236428AbiCBJpF (ORCPT ); Wed, 2 Mar 2022 04:45:05 -0500 Received: from smtpbguseast1.qq.com (smtpbguseast1.qq.com [54.204.34.129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2EAE580D4 for ; Wed, 2 Mar 2022 01:44:20 -0800 (PST) X-QQ-mid: bizesmtp77t1646214239t4q3lvu0 Received: from localhost.localdomain (unknown [58.240.82.166]) by bizesmtp.qq.com (ESMTP) with id ; Wed, 02 Mar 2022 17:43:53 +0800 (CST) X-QQ-SSF: 01400000002000C0G000000A0000000 X-QQ-FEAT: xyySF+ktKzc8o0sxazVfL1OaxjVY3Ht/nzDo91W+cec1vfOJK2+P94HZr5Ta2 2svAAD6EXCc6FpllvhLHSRkQZSWQLRbN9BXofmljew6Fqk71bOe0o3qhGINLhBHZLOKgs1f PItROfzgeQocrtvNjXK9FeMRFGC3aSm94bNhe0iuFpY8sC2+KvAzGFWUO4yCfBC78dknjp7 7jzOGJavoBZNNGBaK1PLhZ/Eu9SgloLY/UD4fouNLDcV8+o0A0iLmwentlUbnJfTo4bG3Lr Z7ee8MZMuCuzdZlY4bTSFCuRSoeBiaM6FT+mJRTES3g73bXsFJ3GrtP/6IvpkJmqYiO58AX A/9Paf8C8yoApWoQcUjU/QlLxKUwVYZNRBWC4BpRAHvpac8vJWPu8YSWYYvNg== X-QQ-GoodBg: 1 From: Meng Tang To: perex@perex.cz, tiwai@suse.com, lgirdwood@gmail.com, broonie@kernel.org Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Meng Tang Subject: [PATCH] ASoC: hdac_hda: Avoid unexpected match when pcm_name is "Analog" Date: Wed, 2 Mar 2022 17:43:51 +0800 Message-Id: <20220302094351.3487-1-tangmeng@uniontech.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: bizesmtp:uniontech.com:qybgforeign:qybgforeign6 X-QQ-Bgrelay: 1 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no 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 pcm name can be "Analog" and "Alt Analog", cpcm->name can be "Analog Codec DAI" and "Alt Analog Codec DAI". When pcm_name is "Analog", "Analog Codec DAI" and "Alt Analog Codec DAI" are both satisfy the 'if (strstr(cpcm->name, pcm_name))' condition, which may cause the returned cpcm to be "Alt Analog Codec DAI". Even if we get the pcm name by id, and "Analog Codec DAI" goes into the loop before "Alt Analog Codec DAI", but I still think we'd better have multiple insurances against unexpected return values. After, we can correctly return the expected result even if other relevant places are changed. Signed-off-by: Meng Tang --- sound/soc/codecs/hdac_hda.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/hdac_hda.c b/sound/soc/codecs/hdac_hda.c index 667f3df239c7..a9f61c7e44ee 100644 --- a/sound/soc/codecs/hdac_hda.c +++ b/sound/soc/codecs/hdac_hda.c @@ -363,8 +363,13 @@ static struct hda_pcm *snd_soc_find_pcm_from_dai(struct hdac_hda_priv *hda_pvt, } list_for_each_entry(cpcm, &hcodec->pcm_list_head, list) { - if (strstr(cpcm->name, pcm_name)) + if (strstr(cpcm->name, pcm_name)) { + if (strcmp(pcm_name, "Analog") == 0) { + if (strstr(cpcm->name, "Alt Analog")) + continue; + } return cpcm; + } } dev_err(&hcodec->core.dev, "didn't find PCM for DAI %s\n", dai->name); -- 2.20.1