From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B4ADAC433E0 for ; Wed, 29 Jul 2020 16:07:26 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3ECDB20809 for ; Wed, 29 Jul 2020 16:07:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="OGkIZy52" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3ECDB20809 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=alsa-devel-bounces@alsa-project.org Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id B42D21707; Wed, 29 Jul 2020 18:06:34 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B42D21707 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1596038844; bh=xMGNiPd9oOoY0TqF7HmJ6+TmULvYjmMOhHM5l0BvRLM=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=OGkIZy52ifK5PpkZ6wYv8RIYAt/Gkdzkh9JW5PtP5nfSm7D/aKDUC1+aUZVTfY8C8 dhXGVifzDSLJ6s2hLi/oweqhvyp5GOhUVQv6ZN1VeyV9Uen4sbML2R7DaAeCLAl3SQ RnGRNVA0R18+mX0WIgOPTOyRSctrQyGrYBEjd7q0= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 215AAF8012F; Wed, 29 Jul 2020 18:06:34 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 93754F801A3; Wed, 29 Jul 2020 18:06:32 +0200 (CEST) Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A3A06F800DE for ; Wed, 29 Jul 2020 18:06:26 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A3A06F800DE X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 62D0DAF8D; Wed, 29 Jul 2020 16:06:37 +0000 (UTC) Date: Wed, 29 Jul 2020 18:06:25 +0200 Message-ID: From: Takashi Iwai To: Ranjani Sridharan Subject: Re: [PATCH] ALSA: hda: fix NULL pointer dereference during suspend In-Reply-To: <862d7184dac6dea172d94b83f2ca7dd29136d2df.camel@linux.intel.com> References: <20200728231011.1454066-1-ranjani.sridharan@linux.intel.com> <862d7184dac6dea172d94b83f2ca7dd29136d2df.camel@linux.intel.com> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Cc: yong.zhi@intel.com, alsa-devel@alsa-project.org, broonie@kernel.org, Pierre-Louis Bossart , tiwai@suse.com X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: "Alsa-devel" On Wed, 29 Jul 2020 17:03:22 +0200, Ranjani Sridharan wrote: > > On Wed, 2020-07-29 at 09:48 +0200, Takashi Iwai wrote: > > On Wed, 29 Jul 2020 01:10:11 +0200, > > Ranjani Sridharan wrote: > > > When the ASoC card registration fails and the codec component > > > driver > > > never probes, the codec device is not initialized and therefore > > > memory for codec->wcaps is not allocated. This results in a NULL > > > pointer > > > dereference when the codec driver suspend callback is invoked > > > during > > > system suspend. Fix this by returning without performing any > > > actions > > > during codec suspend/resume if the card was not registered > > > successfully. > > > > > > Reviewed-by: Pierre-Louis Bossart < > > > pierre-louis.bossart@linux.intel.com> > > > Signed-off-by: Ranjani Sridharan > > > > > > > The code changes look OK to apply, but I still wonder how the runtime > > PM gets invoked even if the device is not instantiated properly? > Hi Takashi, > > Its not runtime PM suspend but rather the system PM suspend callback > that is invoked when the system is suspended that ends up callling the > the runtime PM callback. So, the sequence is: > hda_codec_pm_suspend() > -> pm_runtime_force_suspend() > -> hda_codec_runtime_suspend() OK, but the problem is still same. The basic problem is that the hda_codec_driver_probe() is called for the hda_codec object that hasn't been initialized and bypasses to ext_ops.hdev_attach. So, we can factor out the fundamental part of snd_hda_codec_device_new() that is irrelevant with the card object and call it in hdac_hda_dev_probe(). Most of the legacy HD-audio codec can work without the card object, including suspend/resume. But this will be a more intensive surgery, and maybe not much worth for the corner case, so I already applied your patch as is. thanks, Takashi