Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp464702imu; Wed, 16 Jan 2019 02:02:11 -0800 (PST) X-Google-Smtp-Source: ALg8bN6Nwf5bZXmYIy6utc8qrMtnJA08Ns5t7yzc+prV/mACLil6KwIGDhc6HXEyarPEHMFBiTiQ X-Received: by 2002:a63:4948:: with SMTP id y8mr8129866pgk.32.1547632931126; Wed, 16 Jan 2019 02:02:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547632931; cv=none; d=google.com; s=arc-20160816; b=bdyFbwpfujrxYdNzSsfs4mnZm/ezimRT+uPPpfklIyiqe6ZB25544S3sTVCQFbP1Al D882bNjsxy7kfRNYuZfYmsohrCagpI+UZmdTzP/NtgMLhd/GxbiB2D3+jeLEO3tjsaRh Nfrwkm4fyv1FcxJxT2sA+l2yJXoe2kpeT+00O4yq8YYqMnSSY2v9NF2UHFq7EW8/u3YA 7ecF9FcF6iSR77E0fO+3NlXSSshjtgRdjQpcG1zgnEtPFQnYR/lTt+Jx/+Jv6fB8Iwuj lf2jJUpNP1IL88Uadp7PLYPNIai8qoMLVNZ1Jr//N8WB9KOIWf4WSrZYMZ6di2iMNc3t MBDg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=jkMqjuyuUpDk0A9U6nTYQMPL81T/6VaA7UZAHPL7GyU=; b=Y8du0FR3+7TW1xFHClGDiihBCnjXvXocpZX86AxxnkApbZfbfCOFbvnK3rPbr/m72P 2kzWtVCfmuQVbqwvIdvqNIvXyTr4alOVN+ZF6tXSIMlGWSvVsLQ4Citu/XPA9M3AcEVf PO9oICZ2tM3p+FpaeyjIDXJ09F6S9ELdi/jGPhob19PkpkjC72N4oGNt4wFqQRYLbsw8 ZvBEXXlbBwdA358BI7PQd4iFEn8+5bZv1/RyvGFOSoudhmHCweI0yS87lMukvtugMD1Y +1knP6SYa4nIgjxsE176sMo13n80cwaQcoRJFhg81zEv5oQwfYdS7RIdlOWa4g7GC4Ny UTNQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z61si6055674plb.49.2019.01.16.02.01.52; Wed, 16 Jan 2019 02:02:11 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389353AbfAOTfK (ORCPT + 99 others); Tue, 15 Jan 2019 14:35:10 -0500 Received: from mga09.intel.com ([134.134.136.24]:22878 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731673AbfAOTfK (ORCPT ); Tue, 15 Jan 2019 14:35:10 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 15 Jan 2019 11:35:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,483,1539673200"; d="scan'208";a="108496456" Received: from sdjohn-mobl.amr.corp.intel.com (HELO [10.254.105.1]) ([10.254.105.1]) by orsmga006.jf.intel.com with ESMTP; 15 Jan 2019 11:35:07 -0800 Subject: Re: [alsa-devel] [PATCH] ASoC: soc-core: Fix null pointer dereference in soc_find_component To: Mark Brown Cc: rohkumar@qti.qualcomm.com, alsa-devel@alsa-project.org, bgoswami@codeaurora.org, vinod.koul@linaro.org, linux-kernel@vger.kernel.org, plai@codeaurora.org, tiwai@suse.com, lgirdwood@gmail.com, Ajit Pandey , Liam Girdwood , Rohit kumar , asishb@codeaurora.org, srinivas.kandagatla@linaro.org References: <1547194442-1487-1-git-send-email-rohitkr@codeaurora.org> <4886ed21-65d2-159d-afcd-bb26dcde636e@linux.intel.com> <20190115000610.GM11073@sirena.org.uk> From: Pierre-Louis Bossart Message-ID: <796a856c-a9a6-022d-da63-947279090198@linux.intel.com> Date: Tue, 15 Jan 2019 13:35:07 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20190115000610.GM11073@sirena.org.uk> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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() ??? /* ??? ?* 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?