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=-10.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 A9774C433DF for ; Wed, 29 Jul 2020 07:49:09 +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 33AEB20838 for ; Wed, 29 Jul 2020 07:49:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="ApkWUAiA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 33AEB20838 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 B1F8A1745; Wed, 29 Jul 2020 09:48:17 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz B1F8A1745 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1596008947; bh=04vUzhvtyGYrMJ+omFDX8FtTionI1laOLHNEVzm8cvY=; h=Date:From:To:Subject:In-Reply-To:References:Cc:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=ApkWUAiAkJXrqiKYrq4IaWeTYf00/1zj8ZF1hHtFE5bmUF/6QwmJpsZxv/rqQIn4X WwkjtCYhrf7F2cfNl/oVHW3knVpVVnhNjV9VCPBoE1ljGNWPdyJVdt+4WxGxc0FAnQ apIhyrB9gHs2c48r7ULAF9N7BcYFVnk+RKGNp/1Q= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id 46812F80171; Wed, 29 Jul 2020 09:48:17 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 5C0F0F801A3; Wed, 29 Jul 2020 09:48:15 +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 8D790F80125 for ; Wed, 29 Jul 2020 09:48:08 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 8D790F80125 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 C1799ACA0; Wed, 29 Jul 2020 07:48:19 +0000 (UTC) Date: Wed, 29 Jul 2020 09:48:08 +0200 Message-ID: From: Takashi Iwai To: Ranjani Sridharan Subject: Re: [PATCH] ALSA: hda: fix NULL pointer dereference during suspend In-Reply-To: <20200728231011.1454066-1-ranjani.sridharan@linux.intel.com> References: <20200728231011.1454066-1-ranjani.sridharan@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: Pierre-Louis Bossart , alsa-devel@alsa-project.org, broonie@kernel.org, tiwai@suse.com, yong.zhi@intel.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 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 > 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? thanks, Takashi > --- > sound/pci/hda/hda_codec.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c > index 3576e2d8452f..9b1f387d18e5 100644 > --- a/sound/pci/hda/hda_codec.c > +++ b/sound/pci/hda/hda_codec.c > @@ -2936,6 +2936,10 @@ static int hda_codec_runtime_suspend(struct device *dev) > struct hda_codec *codec = dev_to_hda_codec(dev); > unsigned int state; > > + /* Nothing to do if card registration fails and the component driver never probes */ > + if (!codec->card) > + return 0; > + > cancel_delayed_work_sync(&codec->jackpoll_work); > state = hda_call_codec_suspend(codec); > if (codec->link_down_at_suspend || > @@ -2950,6 +2954,10 @@ static int hda_codec_runtime_resume(struct device *dev) > { > struct hda_codec *codec = dev_to_hda_codec(dev); > > + /* Nothing to do if card registration fails and the component driver never probes */ > + if (!codec->card) > + return 0; > + > codec_display_power(codec, true); > snd_hdac_codec_link_up(&codec->core); > hda_call_codec_resume(codec); > -- > 2.25.1 >