Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2097912ybl; Thu, 30 Jan 2020 11:18:59 -0800 (PST) X-Google-Smtp-Source: APXvYqw8FuZGOx7hGWtchyPgxBxcLZeyDXxTW6ZnDGeog+WCXcLUkWnP1I9OmAd33jBW41FM2qQf X-Received: by 2002:a9d:7e8a:: with SMTP id m10mr4452175otp.27.1580411939290; Thu, 30 Jan 2020 11:18:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580411939; cv=none; d=google.com; s=arc-20160816; b=EW57PeBqOWstNB0+onWUdJqIO9gr70q5S9AdlhWSrWONOG9XtmzTqTLI0B4kWslZMY 8JrCE8xp8tJl0wQDaxQ5gRZtjIcydg9dHQTv0fUpCIN1vzIaUsu8WFPIolvJAa8/PVI+ kEU33XUTsGzc1OKb71v2wsEMMF3EDH6nSgrjI86ooFmUMJ22+Z8LKX4qq7+hWALDFX8W IXjI4u8LF1ozWhK3U6zk9mn85vRqXPodmmQxva4IZWmk+Pr45lRfO7EI8nPFfU+d/WHy J9jScv++wEUCySwtzPXp29ubyB1SYvIBXLOWBUM5y1qli+vNmhipkwbmwT7cU4ZUhyIV RIrw== 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=X9ZDwexlztJxlzHMYrMhylw7aaaEu2nFQ8XFVv3PpDQ=; b=FajWTH7J2ct/RdRMlL+/NPiTGkdYVnvscJxewtkQFeW0AhBVe1V5gXOs9OtRsmq2/y yn4sI1ao9fdaOKmB8RiRiEBN3Oe5gsg/aU4V477sAu4wYE5ZpJsNJ2SSbWZCxU/PFUJP knWjLBlBJeUGqIWXBOG0biq0fvonNniOo5SsP1aI+ZXXwlRvkyoFaW8AOR1CDy0prlPX 5cQ8DEafwH+7ouqaz15AWlRSxzBQvT2mkGtxvJDlEFE/t0zrzd2Y8bl82dmc+FFvTzMb w4yT7n0hkqktk2a7ZFaT/OE8+dAD8impShRUob/QKQfoRaW+FlzLz1/B1QyuGAQ+SFuZ z9tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UcaGNdzj; 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 t18si3497066otc.230.2020.01.30.11.18.46; Thu, 30 Jan 2020 11:18:59 -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=UcaGNdzj; 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 S1730970AbgA3SpL (ORCPT + 99 others); Thu, 30 Jan 2020 13:45:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:54634 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730690AbgA3SpJ (ORCPT ); Thu, 30 Jan 2020 13:45:09 -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 8ECFA205F4; Thu, 30 Jan 2020 18:45:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1580409908; bh=CKCrECNmgHj6S4af5+GDElQKarJnX+Ott2IWHk8nNoo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UcaGNdzj9gmyz52f93wZtCh9OSy2ahCC/J1jhPxka90VPpZtp6FI+Z52ga4S4iMhR bjjylz6UqN90eq3U/M5VfnEKjmcLR34iV8aKgGXWaCQs6FC1xqHTLK6d2hCKBGOiwr y/5HNEN9QtaBkAJLiTt0fvnywoGT15NMQTG+VwTY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ranjani Sridharan , Kai Vehmanen , Pierre-Louis Bossart , Mark Brown , Sasha Levin Subject: [PATCH 5.4 053/110] ASoC: SOF: Intel: hda: hda-dai: fix oops on hda_link .hw_free Date: Thu, 30 Jan 2020 19:38:29 +0100 Message-Id: <20200130183621.422518579@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: Pierre-Louis Bossart [ Upstream commit 921162c81a089aa2f442103290f1af9ba281fc9f ] When the PCM_PARAM IPC fails while configuring the FE, the kernel oopses in the HDaudio link DMA .hw_free operation. The root cause is a NULL dma_data since the BE .hw_params was never called by the SOC core. This error can also happen if the HDaudio link DMA configuration IPC fails in the BE .hw_params. This patches makes sure the dma_data is properly saved in .hw_params, and tested before being use in hw_free. GitHub issue: https://github.com/thesofproject/linux/issues/1417 Reviewed-by: Ranjani Sridharan Reviewed-by: Kai Vehmanen Signed-off-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20191218000518.5830-3-pierre-louis.bossart@linux.intel.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/sof/intel/hda-dai.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/sound/soc/sof/intel/hda-dai.c b/sound/soc/sof/intel/hda-dai.c index 8796f385be76c..896d21984b735 100644 --- a/sound/soc/sof/intel/hda-dai.c +++ b/sound/soc/sof/intel/hda-dai.c @@ -216,6 +216,8 @@ static int hda_link_hw_params(struct snd_pcm_substream *substream, link_dev = hda_link_stream_assign(bus, substream); if (!link_dev) return -EBUSY; + + snd_soc_dai_set_dma_data(dai, substream, (void *)link_dev); } stream_tag = hdac_stream(link_dev)->stream_tag; @@ -228,8 +230,6 @@ static int hda_link_hw_params(struct snd_pcm_substream *substream, if (ret < 0) return ret; - snd_soc_dai_set_dma_data(dai, substream, (void *)link_dev); - link = snd_hdac_ext_bus_get_link(bus, codec_dai->component->name); if (!link) return -EINVAL; @@ -361,6 +361,13 @@ static int hda_link_hw_free(struct snd_pcm_substream *substream, bus = hstream->bus; rtd = snd_pcm_substream_chip(substream); link_dev = snd_soc_dai_get_dma_data(dai, substream); + + if (!link_dev) { + dev_dbg(dai->dev, + "%s: link_dev is not assigned\n", __func__); + return -EINVAL; + } + hda_stream = hstream_to_sof_hda_stream(link_dev); /* free the link DMA channel in the FW */ -- 2.20.1