Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2097048ybl; Thu, 30 Jan 2020 11:18:09 -0800 (PST) X-Google-Smtp-Source: APXvYqztPsS1LPsgAaVYqKNzMgYUDS9TBS8+DkXdUMF/8tDJTgSUup02SA8NeTTS2QGIJdJ0DguU X-Received: by 2002:a05:6830:12d5:: with SMTP id a21mr4874154otq.296.1580411889832; Thu, 30 Jan 2020 11:18:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580411889; cv=none; d=google.com; s=arc-20160816; b=SEMkEwkXbXUaLvkdcZ2mUsJ/bw/devE7kQ/LHOd+Pt0iVh/gej1djdRqvYkHyQeT0n MC6H4d89X+piHMi6cg7ebyEr52dzZxP3yaN6xR2C6uMEBmG1Rha2dLVN6MRPOQjF+SyR qxAgvIUrBfSvDbTHsnygoQAp8lByq2DXdxD0oEtXihGXXsddp2OG1PO2yPryNqLDd/um S71XjHRt46fNSTUViNtE0o1FHvOl0KIo7PqV5ACaPMVuXUC9lzTkMdNJkxEl/j60j1GF ADe+WjA3fkkzHojp9yITT7IM1mrEs27RQFlutLFmiS//SHX1DbV6NVcYLxWPhQfzSIOG Xy2A== 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=t7nC3iNmRUtyZJZ2vhIVc4pVXZ91h0QOlsQ7jHTUrdM=; b=wbPL5JdztjidvMwvOme7mQ0fjVlb9Gq7Yj6k5at2lbgUMRMaWCrRO59FyqZrld2q0P 6q4kofzyexbvsOLdNRDdMU19+a5EZAZR63iE2scm4RVEnvdU6Ih1SP6pRlyMekjdAXGY pS8CFS/0WQuOgiH6C6216XItJFxveC7draxMwQvcmBnYMFleqeZkKuGv+ESO3mAghnNI d2U68F5LRlVA6C2WYHzVNIVUvvi3Nb4SWy7PySeqtmQhdJmnJMQ3eXhPZhk6y6UyU3jP dfc6dHuugamHZ24SPEQyC2kKzEA2xiTVAKowyj9DEaB8AU0zQ50VIDt8kfj1WYsuw/DN lo9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=cJgS8pS6; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g24si3542796otj.59.2020.01.30.11.17.58; Thu, 30 Jan 2020 11:18:09 -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; dkim=pass header.i=@kernel.org header.s=default header.b=cJgS8pS6; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730863AbgA3Som (ORCPT + 99 others); Thu, 30 Jan 2020 13:44:42 -0500 Received: from mail.kernel.org ([198.145.29.99]:53884 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730563AbgA3Sok (ORCPT ); Thu, 30 Jan 2020 13:44:40 -0500 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 2E5C0205F4; Thu, 30 Jan 2020 18:44:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580409879; bh=D9R14nx92DgiSI7HrKBJtY8GmlzoUhNOx/S3N6SKvzc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cJgS8pS6sbVnaFvCKkc7wprMvPwp0827jcG6tjkdis64dwH/8gRCIV9ClgZAhpOMa jh+WvliZpa+W+HyjHldndeXf4+u6ky5R66ou8hWFotVlzJZfm8zq73Dh8jzZFlIkbv FNywdN5tZHMynD74W1StVrBW/m6Kgs8jKu3TtLyU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kai Vehmanen , Pierre-Louis Bossart , Mark Brown , Sasha Levin Subject: [PATCH 5.4 052/110] ASoC: SOF: fix fault at driver unload after failed probe Date: Thu, 30 Jan 2020 19:38:28 +0100 Message-Id: <20200130183621.303656639@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200130183613.810054545@linuxfoundation.org> References: <20200130183613.810054545@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: Kai Vehmanen [ Upstream commit b06e46427f987bf83dcb6a69516b57276eb8ec0c ] If sof_machine_check() fails during driver probe, the IPC state is not initialized and this will lead to a NULL dereference at driver unload. Example log is as follows: [ 1535.980630] sof-audio-pci 0000:00:1f.3: error: no matching ASoC machine driver found - aborting probe [ 1535.980631] sof-audio-pci 0000:00:1f.3: error: failed to get machine info -19 [ 1535.980632] sof-audio-pci 0000:00:1f.3: error: sof_probe_work failed err: -19 [ 1550.798373] BUG: kernel NULL pointer dereference, address: 0000000000000008 ... [ 1550.798393] Call Trace: [ 1550.798397] snd_sof_ipc_free+0x15/0x30 [snd_sof] [ 1550.798399] snd_sof_device_remove+0x29/0xa0 [snd_sof] [ 1550.798400] sof_pci_remove+0x10/0x30 [snd_sof_pci] Signed-off-by: Kai Vehmanen Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191218000518.5830-2-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/sof/ipc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sound/soc/sof/ipc.c b/sound/soc/sof/ipc.c index 086eeeab86795..7b6d69783e16a 100644 --- a/sound/soc/sof/ipc.c +++ b/sound/soc/sof/ipc.c @@ -834,6 +834,9 @@ void snd_sof_ipc_free(struct snd_sof_dev *sdev) { struct snd_sof_ipc *ipc = sdev->ipc; + if (!ipc) + return; + /* disable sending of ipc's */ mutex_lock(&ipc->tx_mutex); ipc->disable_ipc_tx = true; -- 2.20.1