Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp263987pxx; Wed, 28 Oct 2020 04:28:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwvZnxkX6DfBST/EsbKLZIDbVDwIiuXUYk8PkzGnBRYvTMzpsv5Jhcrk5gZvLbZxqdVq3Eh X-Received: by 2002:a17:906:7844:: with SMTP id p4mr6925848ejm.26.1603884482401; Wed, 28 Oct 2020 04:28:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603884482; cv=none; d=google.com; s=arc-20160816; b=Xble4hNNvIyzvpi3+YANYyzWc0b5T/3vdgvVOr8xm5sDYR9oFfc6OdudQ6EfDbPpWl lW/8nRigm2GFsz3udzB4KYba90jyRBE2Q364ihXVLcBf/If//qYHPPDALAyNn6RJSHS5 jTWE84KtBAwf9Py1MEkXHJ0wN9vi/wai4MYYjwBT/W/cCyOa+ihEIMcIXyu8yf0Qe8IQ jR8mnzBURCndV1f6td/Vqt+ufDygNK+hIblbf4822s4cftxyUghyIISZ0RU/Z04ty0xO jpfhjgCAFb2Ah0V/7tYXrzlOcXCAYpDDF4GMZy/XNzhXdokV1vc9dXDnaVxADBt7bEk7 UeTg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ITeLiPyB9DohE7S68yptJD/PYV7hon1u0eWpLHJVJjo=; b=OEJJIsL1GNzMdfoN5DCbT9+y2h0CyObaJYf8rPKvNjgr+c3lRx+RxmMlAoy2FWgrw9 5525qsb1r67gED28LJ6yyJkl3zTq/NHZDFxrKAvgtLf7y1QDIjK4sgR4vg+9kQdoH0cN LDSvEZ/m+/kHd6N7if1SSNKTaO3/3FTtzIXiRSNd6ZxEIngMXhc2b0XQgyn4PsZjcq/o oIDJnvXyGFwyFXUxEcYCtILTHyb1RPzbYcIaM4GpnmXvT71xRr5GzjnlRON/mgTltz+x o7XzE0TLnYRfn0LeAQb3e44JDmAHhLlS5TUSVKhfJLivSV3eZJhNsJP/2IJfdg9b90JJ hW3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qfhkQJGq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y19si2789537ejd.730.2020.10.28.04.27.40; Wed, 28 Oct 2020 04:28:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qfhkQJGq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1789707AbgJ0PEF (ORCPT + 99 others); Tue, 27 Oct 2020 11:04:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:34944 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1782057AbgJ0PBM (ORCPT ); Tue, 27 Oct 2020 11:01:12 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D459E22281; Tue, 27 Oct 2020 15:01:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603810871; bh=jTW1jFhzJgf7ndKmuT0h8Et1IBsiqE1+rgRteC+iPVk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qfhkQJGqXWBAxL/RiK1WVv0+wa+Mb3pEWLNczoQPTqgZsgF6FcQEmy8z501UHcN6Z Ax5/eeTRdLTCs7Hn27Tf07REvsJFHJRmd5mNnm2B/Mby2MqB/tmyy0uHMFGBEjYZZT cRlJnCZJkcw2UCVxXRBqP2/3wNH09uRFPgPS3/0Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adam Brickman , Charles Keepax , Mark Brown , Sasha Levin Subject: [PATCH 5.8 293/633] ASoC: wm_adsp: Pass full name to snd_ctl_notify Date: Tue, 27 Oct 2020 14:50:36 +0100 Message-Id: <20201027135536.414812465@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Adam Brickman [ Upstream commit 20441614d89867142060d3bcd79cc111d8ba7a8e ] A call to wm_adsp_write_ctl() could cause a kernel crash if it does not retrieve a valid kcontrol from snd_soc_card_get_kcontrol(). This can happen due to a missing control name prefix. Then, snd_ctl_notify() crashes when it tries to use the id field. Modified wm_adsp_write_ctl() to incorporate the name_prefix (if applicable) such that it is able to retrieve a valid id field from the kcontrol once the platform has booted. Fixes: eb65ccdb0836 ("ASoC: wm_adsp: Expose mixer control API") Signed-off-by: Adam Brickman Signed-off-by: Charles Keepax Link: https://lore.kernel.org/r/20201001152425.8590-1-ckeepax@opensource.cirrus.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/codecs/wm_adsp.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c index 519ca2e696372..18f62fde92537 100644 --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c @@ -2043,6 +2043,7 @@ int wm_adsp_write_ctl(struct wm_adsp *dsp, const char *name, int type, { struct wm_coeff_ctl *ctl; struct snd_kcontrol *kcontrol; + char ctl_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN]; int ret; ctl = wm_adsp_get_ctl(dsp, name, type, alg); @@ -2053,8 +2054,25 @@ int wm_adsp_write_ctl(struct wm_adsp *dsp, const char *name, int type, return -EINVAL; ret = wm_coeff_write_ctrl(ctl, buf, len); + if (ret) + return ret; + + if (ctl->flags & WMFW_CTL_FLAG_SYS) + return 0; + + if (dsp->component->name_prefix) + snprintf(ctl_name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, "%s %s", + dsp->component->name_prefix, ctl->name); + else + snprintf(ctl_name, SNDRV_CTL_ELEM_ID_NAME_MAXLEN, "%s", + ctl->name); + + kcontrol = snd_soc_card_get_kcontrol(dsp->component->card, ctl_name); + if (!kcontrol) { + adsp_err(dsp, "Can't find kcontrol %s\n", ctl_name); + return -EINVAL; + } - kcontrol = snd_soc_card_get_kcontrol(dsp->component->card, ctl->name); snd_ctl_notify(dsp->component->card->snd_card, SNDRV_CTL_EVENT_MASK_VALUE, &kcontrol->id); -- 2.25.1