Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp4419093pxa; Mon, 10 Aug 2020 08:38:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfXGe162qTrToumODJrxznihFBF8Yqf5kf1dM8kXuTUgZB4HcE9qC47hRefEXt8ERM1UKb X-Received: by 2002:a50:8f44:: with SMTP id 62mr22447196edy.3.1597073926021; Mon, 10 Aug 2020 08:38:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597073926; cv=none; d=google.com; s=arc-20160816; b=s0xRFrOt7NOmy0S9RAHDbz7RvkIN2QmDNITrPznsovl76PaqsgjNpmo+5pkYDiO6gX JanvrBJftcH/wyhkH3/Lq9N5PelLCGOqkJv2NZaKFiVrdClXYsBDNNMS1BJz/LQM6daG 6Gw57mo3dGpIikK/ihtfDVHVA2xVkvtRYEIdzkr+McNKljfPLCNdVNlIuxfgAU+3vKug zM6K34HQ2u88FYCf8WjFsHpqYj1csOpXi0UqXOZfir+n968qa1IqekzZdHvN/bvNkBRJ vGelVx0uClM/KlrCKakeMiub8RFpNaBA1tneEFvsalZ3XT3xistQhK+SQy86aZeNZ2HO YpCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=z+j0ZpAlPzFK1k1HfdqilHO/LNIACccjPs1CXKzE1yA=; b=igMpzWIf2VEu3tCeDFrWtaYJ+mVfAQJnqgU3Xyhdp57DhMFPpgdvJkZM2lAche2YK1 Wdor8SvA4/UaOWRK76NJv2RZ6TuyMt3xO3Zae4dYl4ElO2s4SpoqpFcrzW7my3UzrtTJ MHBjedLCTOyVY4Azma/58yZ80VaGN+1pOVo2+JDwIOKUZVhDCT5r2uw7PLr36PBhpwuE P8EhdMtkVAa2i5N/4XqXz5kiwwXAPnKPDjuRcuuau/Oq0eSaq0vHB88AIg7DwDM6vLMZ saYyVE9CaH2CFRtBHYmAHuszoNeDQLkGM9GNh+/CaSJVzCjTcE9PS3gOJjdnCpwFIQFh 34yw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dWd8yXT2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r14si11180215ejy.577.2020.08.10.08.38.23; Mon, 10 Aug 2020 08:38:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=dWd8yXT2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728963AbgHJPgJ (ORCPT + 99 others); Mon, 10 Aug 2020 11:36:09 -0400 Received: from mail.kernel.org ([198.145.29.99]:33442 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728757AbgHJP1d (ORCPT ); Mon, 10 Aug 2020 11:27:33 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 630CA22BF3; Mon, 10 Aug 2020 15:27:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597073252; bh=8DpZJzOA2XOE6mKbWrjqeDu4/W69O4cH8yppwCZN43w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dWd8yXT2IImxw0fRlr4IWyWFkzXotEbpsPSkgHt3a2SXB5asQ2sfv2Jk3iBDf2Lt0 C4WLUAIF7VnjLzzoI3+JyeharsY03Q8awFTi9szU6YqTXrspoKyxe+5u+cRwTFeOUQ wGbZ+DTGBymJyJSepZb8sHKxkSV9srR+Dz0o5sCM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pierre-Louis Bossart , Ranjani Sridharan , Takashi Iwai , Sasha Levin Subject: [PATCH 5.4 40/67] ALSA: hda: fix NULL pointer dereference during suspend Date: Mon, 10 Aug 2020 17:21:27 +0200 Message-Id: <20200810151811.413584797@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200810151809.438685785@linuxfoundation.org> References: <20200810151809.438685785@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ranjani Sridharan [ Upstream commit 7fcd9bb5acd01250bcae1ecc0cb8b8d4bb5b7e63 ] 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 Link: https://lore.kernel.org/r/20200728231011.1454066-1-ranjani.sridharan@linux.intel.com Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- 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 07c03c32715a9..801abf0fc98b3 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -2924,6 +2924,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 || @@ -2938,6 +2942,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