Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp615252imu; Wed, 16 Jan 2019 04:52:21 -0800 (PST) X-Google-Smtp-Source: ALg8bN4EeZJTIrvLTJu2rhavt/Nvezv+NShldWlUoCSUshU8BjxCwxRBUaIZdAZcEx7xyGNUN61/ X-Received: by 2002:a63:82c6:: with SMTP id w189mr8813509pgd.344.1547643141192; Wed, 16 Jan 2019 04:52:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547643141; cv=none; d=google.com; s=arc-20160816; b=gMANZmtrnJYBDIMXSqwdWL+GS2RhrrgPNKi8nC11DXt5RAbt/fPzPVMINvxPCDQiOU sKsW0AE02AsAH1kNTvqPYJlh1echeKRH6AJ8xd7SV/skLxvxlMNGAv5ZDtxsJdbI+Via O1J2poG5Aeegy44qw5QoP/6vL3ISzQfej7aNSxJHrldxpxhgX4dhpcOgFiPTdeFWzufi 7e57qEtuHTpp4a8dPb/UolMCgUE4bleF+7fVCLQsOnqRcZ6Xl6xExYOY+Vq105aYGe0n k+ssz4LHT68hwPr5DajpeUGgykVZjz7/OYKhljo5t1erBUMovTHEXtugIA7DBoUtv8Qq JLyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature; bh=Oz2MYHFzHbvzb/4uDMVUcPJLGRSFPdyJJ/XTEX/Si80=; b=DPGxY1zTbRHDWaXH2p5E9Pmkgh8Nmx0udOt8LLaC1I0pkgtbaqybKtgYiuBT9/HUAE nnIJfFKhmDsEhs42q0DuUPhrXP6YqMjwGX4rz6z0ZUwTDnnHhqek4L+r7c2xFzEzK29x DN7j1IUq1ABhC/pR5RvS/GTCIWuPXExhM13vZynuJJlXm4XxW+ZZIjiOsD7QtLp04i6O LhP5L+HMeuKzfKznV1srTQ+h7JaHu/a4TRWj789CMZ4fLXNDdBfAwP9liVxywP49q+iI Aa4dToExhKaAsXADT9R2vqdpSXrRbnPOZitms/tDUQ9wnN9fB4xqgIueW7kAbxEYDjOt PKVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@horus.com header.s=20180324 header.b=oIZ8ofcP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=horus.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d19si6815941pfd.196.2019.01.16.04.52.05; Wed, 16 Jan 2019 04:52:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@horus.com header.s=20180324 header.b=oIZ8ofcP; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=horus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390256AbfAOVLl (ORCPT + 99 others); Tue, 15 Jan 2019 16:11:41 -0500 Received: from mail.horus.com ([78.46.148.228]:51915 "EHLO mail.horus.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732985AbfAOVLl (ORCPT ); Tue, 15 Jan 2019 16:11:41 -0500 Received: from lenny.lan (62-47-205-132.adsl.highway.telekom.at [62.47.205.132]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "E-Mail Matthias Reichl Lenny", Issuer "HiassofT CA 2014" (verified OK)) by mail.horus.com (Postfix) with ESMTPSA id 2D0A164137; Tue, 15 Jan 2019 22:11:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=horus.com; s=20180324; t=1547586698; bh=Oz2MYHFzHbvzb/4uDMVUcPJLGRSFPdyJJ/XTEX/Si80=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=oIZ8ofcPd1dPvMazLIlVMzRNZHxuzIi5PAhdGvb9UuNcdVsYO2NwGwwO7VTyHTql1 H6u0q/jbjSSVhvqLLAv88Bsh8FGWB4vPgCD77sgrpi3uV3lgRxL5EjGwq+igeV6/b4 9m6yDt/k0tZYTeL0DBJNf9ZgE+XFTomn0r/YdEMY= Received: by lenny.lan (Postfix, from userid 1000) id 8F958100068; Tue, 15 Jan 2019 22:11:37 +0100 (CET) Date: Tue, 15 Jan 2019 22:11:37 +0100 From: Matthias Reichl To: Pierre-Louis Bossart Cc: Mark Brown , rohkumar@qti.qualcomm.com, alsa-devel@alsa-project.org, bgoswami@codeaurora.org, vinod.koul@linaro.org, lgirdwood@gmail.com, plai@codeaurora.org, linux-kernel@vger.kernel.org, tiwai@suse.com, Liam Girdwood , srinivas.kandagatla@linaro.org, Rohit kumar , asishb@codeaurora.org, Ajit Pandey Subject: Re: [alsa-devel] [PATCH] ASoC: soc-core: Fix null pointer dereference in soc_find_component Message-ID: <20190115211137.rhdyjadu7fppp3p4@lenny.lan> Mail-Followup-To: Matthias Reichl , Pierre-Louis Bossart , Mark Brown , rohkumar@qti.qualcomm.com, alsa-devel@alsa-project.org, bgoswami@codeaurora.org, vinod.koul@linaro.org, lgirdwood@gmail.com, plai@codeaurora.org, linux-kernel@vger.kernel.org, tiwai@suse.com, Liam Girdwood , srinivas.kandagatla@linaro.org, Rohit kumar , asishb@codeaurora.org, Ajit Pandey References: <1547194442-1487-1-git-send-email-rohitkr@codeaurora.org> <4886ed21-65d2-159d-afcd-bb26dcde636e@linux.intel.com> <20190115000610.GM11073@sirena.org.uk> <796a856c-a9a6-022d-da63-947279090198@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <796a856c-a9a6-022d-da63-947279090198@linux.intel.com> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jan 15, 2019 at 01:35:07PM -0600, Pierre-Louis Bossart wrote: > > On 1/14/19 6:06 PM, Mark Brown wrote: > > On Fri, Jan 11, 2019 at 03:49:08PM -0600, Pierre-Louis Bossart wrote: > > > > > Adding some traces I can see that the the platform name we use doesn't seem > > > compatible with your logic. All the Intel boards used a constant platform > > > name matching the PCI ID, see e.g. [1], which IIRC is used to bind > > > components. Liam, do you recall in more details if this is really required? > > That's telling me that either snd_soc_find_components() isn't finding > > components in the same way that we do when we bind things which isn't > > good or we're binding links without having fully matched everything on > > the link which also isn't good. > > > > Without a system that shows the issue I can't 100% confirm but I think > > it's the former - I'm fairly sure that those machines are relying on the > > component name being initialized to fmt_single_name() in > > snd_soc_component_initialize(). That is supposed to wind up using > > dev_name() (which would be the PCI address for a PCI device) as the > > basis of the name. What I can't currently see is how exactly that gets > > bound (or how any of the other links avoid trouble for that matter). We > > could revert and push this into cards but I would rather be confident > > that we understand what's going on, I'm not comfortable that we aren't > > just pushing the breakage around rather than fixing it. Can someone > > with an x86 system take a look and confirm exactly what's going on with > > binding these cards please? > > Beyond the fact that the platform_name seems to be totally useless, > additional tests show that the patch ('ASoC: soc-core: defer card probe > until all component is added to list') adds a new restriction which > contradicts existing error checks. > > None of the Intel machine drivers set the dailink "cpu_name" field but use > the "cpu_dai_name" field instead. This was perfectly legit as documented by > the code at the end of soc_init_dai_link() This should be fixed by the patch "ASoC: core: Don't defer probe on optional, NULL components" which Mark already applied to his tree. See http://mailman.alsa-project.org/pipermail/alsa-devel/2019-January/144323.html Maybe the defer card probe logic needs to be extended to also check if dai_link_name had already been registered (either cpu or cpu_dai_name needs to be set), not 100% sure which problem the defer card probe patch was trying to solve. so long, Hias > > ??? /* > ??? ?* At least one of CPU DAI name or CPU device name/node must be > ??? ?* specified > ??? ?*/ > ??? if (!link->cpu_dai_name && > ??? ??? !(link->cpu_name || link->cpu_of_node)) { > ??? ??? dev_err(card->dev, > ??? ??? ??? "ASoC: Neither cpu_dai_name nor cpu_name/of_node are set for > %s\n", > ??? ??? ??? link->name); > ??? ??? return -EINVAL; > ??? } > > The code contributed by Qualcomm only checks for cpu_name, which prevents > the init from completing. > > So if we want to be consistent, the new code should be something like: > > diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c > index b680c673c553..2791da9417f8 100644 > --- a/sound/soc/soc-core.c > +++ b/sound/soc/soc-core.c > @@ -1154,7 +1154,7 @@ static int soc_init_dai_link(struct snd_soc_card > *card, > ???????? * Defer card registartion if cpu dai component is not added to > ???????? * component list. > ???????? */ > -?????? if (!soc_find_component(link->cpu_of_node, link->cpu_name)) > +?????? if (!link->cpu_dai_name && !soc_find_component(link->cpu_of_node, > link->cpu_name)) > ??????????????? return -EPROBE_DEFER; > > ??????? /* > > or try to call soc_find_component with both cpu_name or cpu_dai_name, if > this makes sense? > _______________________________________________ > Alsa-devel mailing list > Alsa-devel@alsa-project.org > http://mailman.alsa-project.org/mailman/listinfo/alsa-devel