Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3685491imu; Fri, 18 Jan 2019 15:12:12 -0800 (PST) X-Google-Smtp-Source: ALg8bN6UKrpxzaaczPvv0QaiFtQMYvzZwFpKvbX0lejBRrg0wjg5pfFsNZuqiDMdg3eXR6htFJe+ X-Received: by 2002:a63:2ac9:: with SMTP id q192mr19668430pgq.58.1547853132894; Fri, 18 Jan 2019 15:12:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547853132; cv=none; d=google.com; s=arc-20160816; b=ATmI7ZK03rADVRAF+3p5PXMn0+i2y54rPNaa1/P6QsfyNwND6QQ3+zWgu6h+oJafwR 0eVLJjc7ePquoX3cG6jsts451y8xx2/3zmFTJ1XDIDK0hsE829E7vx49+jUlcao3F8D5 sDTrB74WtRI/7LN2TM+TrfV06scLAB1A01iHuGQyxq17FtCPKUYRXqpYtxxi4f5RxNmX J61G30svk1e0eO35EyypsFgL1WyCXC/hRqdUWmRxOWEYIbi648d0sxAIB8CzgHQ1Orno Thyue6KNofzTSRFhstwHx0b6rT3PEtpQ1kEJz/iZrgJe73PleFEeug2FavtGAfnikpD4 ls6Q== 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:references:to:from:subject; bh=Tx2xBNIxCbE7crG6s6RY5rvC8lVdO94+rlqiQ7Xz8aQ=; b=C9PeD9BNqVaG2xA8r0uqjOlJpf3yCu3NvjNaJuK5UB+W4FAQ2n0NVNZ1gvWFafcp2O AQ4Mr7TKorUW3VOvvuvp0DArQctiCoLahH4rJMreCroR1QgwRO7aUAI8cdYUWEvvgWoy Sq67F1+yd9t6QJC7m0zeIi0/UFdJPVT6i7m9nCtZYSciaSJ67NjohYFjCYtd2+TLENR1 /g/ZVX4maEAHI+S8MOVRRPBfAsceVRZMGz4EyZ/adyDmAmEa36+IA1qV71nzLbMlIMWN cTW1LCVT1K9CxypAFrk9pSg3ze4xEPbEkC/oTHvg7MEmEewsc24KFG0nMbanu/xxF3PQ YNCA== 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 v185si5817697pfb.65.2019.01.18.15.11.57; Fri, 18 Jan 2019 15:12:12 -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 S1730008AbfARXCM (ORCPT + 99 others); Fri, 18 Jan 2019 18:02:12 -0500 Received: from mga02.intel.com ([134.134.136.20]:13224 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729780AbfARXCL (ORCPT ); Fri, 18 Jan 2019 18:02:11 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jan 2019 15:02:10 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,492,1539673200"; d="scan'208";a="126966883" Received: from svenka7-mobl.amr.corp.intel.com (HELO [10.251.144.131]) ([10.251.144.131]) by FMSMGA003.fm.intel.com with ESMTP; 18 Jan 2019 15:02:08 -0800 Subject: Re: [alsa-devel] [PATCH] ASoC: soc-core: Fix null pointer dereference in soc_find_component From: Pierre-Louis Bossart To: Matthias Reichl , 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 , Curtis Malainey 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> <20190115211137.rhdyjadu7fppp3p4@lenny.lan> Message-ID: <044d59ba-094e-727d-14a9-6ebfc54cbbf4@linux.intel.com> Date: Fri, 18 Jan 2019 17:02:08 -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: Content-Type: text/plain; charset=utf-8; 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/15/19 3:16 PM, Pierre-Louis Bossart wrote: > >>> 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 >> > > Ah yes, I missed this patch while I was debugging. Indeed this fixes > the problem and my devices work again with Mark's for-next branch. > Thanks Matthias! This PROBE_DEFER support actually breaks the topology override that we've been relying on for SOF (and which has been in Mark's branch for some time now). This override helps us reuse machine drivers between legacy and SOF-based solutions. With the current code, the tests in soc_register_card() complain that the platform_name can't be tied to a component and stop the card registration, but that's mainly because the tests are done before the topology overrides are done in soc_check_tplg_fes(). Moving soc_check_tplg_fes() from soc_instantiate_card() to an earlier time in soc_register_card() works-around the problem but looks quite invasive (mutex lock, etc). There is also a second problem where we seem to have a memory management issue root caused to the change in snd_soc_init_platform() added by 09ac6a817bd6 ('ASoC: soc-core: fix init platform memory handling') The code does this static int snd_soc_init_platform(struct snd_soc_card *card,                  struct snd_soc_dai_link *dai_link) {     struct snd_soc_dai_link_component *platform = dai_link->platform;     /* convert Legacy platform link */     if (!platform || dai_link->legacy_platform) {         platform = devm_kzalloc(card->dev,                 sizeof(struct snd_soc_dai_link_component),                 GFP_KERNEL);         if (!platform)             return -ENOMEM;         dai_link->platform      = platform;         dai_link->legacy_platform = 1; This last assignment guarantees that memory will be allocated every time this function is called, and whatever overrides are done later will themselves be overridden by the new allocation. I am not sure what the intent was here, Curtis can you please double-check? Details, test code and logs are available here: https://github.com/thesofproject/linux/issues/565 Have a nice week-end everyone, that's it for me until Tuesday. -Pierre