Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp1724747pxb; Wed, 9 Feb 2022 03:10:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJwU/M35A8LGTWJ4In/Ymw8NQor3W8VP4vyifQazL1T/yuooTeyzRhZPpgnUti2sfh0SYipo X-Received: by 2002:a17:906:1454:: with SMTP id q20mr1468431ejc.461.1644405054516; Wed, 09 Feb 2022 03:10:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644405054; cv=none; d=google.com; s=arc-20160816; b=DvbSj51hSZKprLGuSvqa4A/sbTwg9yMGkxoDOm/MbNo0QoMxZgRZLpPEL//XWk9mFL NmCvRIm7fQU6g2yfLzYxVH5X/sTTQLNd+XoHdgthSkCBlR/3RdljKGC5tWcoAzCJjgpN uw2mQBvotYlQybcGoA28czN959wFJHQhMJfakWNvDSZpkCn6qfxHPyVsVYpIWfuw5iJ5 msg31eKysbc73gleUhPadIdmpGClmxvXAk5TJNBNvq6qvcyazFcZQoo81PdlLkpHmpa5 IqelQGZqR1bn5Dh8Ieoy7HHpW7cpRxb5PNXZZsQP89g6tnl1SDauIMu5/X6IZlv/E6Nq T17w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=PSag0jyO4clOJkiY2psq3NGgw7w62TfedJ48tq1LAVA=; b=LfZVIn5tQ7kfdqFblDo7tlvmd0vnh+pB3iYZPR95jc54DRiFi8prVQ3EA6FZGh41z7 6QGAJXdjLq1+OonzN4pth/K4q+NoxL+B2IKFoekqpE4yRUx6an/bhQDguEJm9mzk9S48 iO9rOo7OMjqydtanthp+/59WDoHg10W9G3Y0rTjpbKBZ4kzlCc32B64Por1o2d5t7av7 m1QZyLIqHgPFbqtuh25eScOivUM7iEmY+w0YHgPMcYB7+8zPnbnO0uP/Axyg3DE7G0lA bUw18Xgs5NJqBdoAhqzqmyVqdGJVJJUAS1OhR3xtCjJDZbSbLrlHUHGrlJReaM7a4jGK LUQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=0f5GyFz8; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n2si11550864edi.143.2022.02.09.03.10.29; Wed, 09 Feb 2022 03:10:54 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=0f5GyFz8; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1387639AbiBGLl1 (ORCPT + 99 others); Mon, 7 Feb 2022 06:41:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359797AbiBGL2q (ORCPT ); Mon, 7 Feb 2022 06:28:46 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B186C02C451; Mon, 7 Feb 2022 03:27:03 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id F34C0B81158; Mon, 7 Feb 2022 11:26:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 363CFC004E1; Mon, 7 Feb 2022 11:26:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1644233199; bh=wgI2JfwnGs9YATRBKGTUEYM00WplHCkNomidae7ocq0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0f5GyFz8ib+wdXvFIXOKyyBEOyLmUovADcSXUPARbrOlxheWnIj3ylNf3aO0QkTeY lC5nyeevmeEda4WpjmZMyW+ChmbjlsfKgBqQW8v7QRHottzOI7yDQSVcSsQTDWhVnT 037/OvvJEq11w6g3SYpB+UgJRzMnsG2yaurghuD0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Guennadi Liakhovetski , Peter Ujfalusi , Takashi Iwai Subject: [PATCH 5.15 047/110] ALSA: hda: Skip codec shutdown in case the codec is not registered Date: Mon, 7 Feb 2022 12:06:20 +0100 Message-Id: <20220207103803.876984550@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220207103802.280120990@linuxfoundation.org> References: <20220207103802.280120990@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Peter Ujfalusi commit 1c7f0e349aa5f8f80b1cac3d4917405332e14cdf upstream. If the codec->registered is not set then it means that pm_runtime is not yet enabled and the codec->pcm_list_head has not been initialized. The access to the not initialized pcm_list_head will lead a kernel crash during shutdown. Reported-by: Guennadi Liakhovetski Signed-off-by: Peter Ujfalusi Tested-by: Guennadi Liakhovetski Fixes: b98444ed597d ("ALSA: hda: Suspend codec at shutdown") Link: https://lore.kernel.org/r/20220201112144.29411-1-peter.ujfalusi@linux.intel.com Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/pci/hda/hda_codec.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c @@ -3000,6 +3000,10 @@ void snd_hda_codec_shutdown(struct hda_c { struct hda_pcm *cpcm; + /* Skip the shutdown if codec is not registered */ + if (!codec->registered) + return; + list_for_each_entry(cpcm, &codec->pcm_list_head, list) snd_pcm_suspend_all(cpcm->pcm);