From patchwork Tue Feb 18 14:10:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cezary Rojewski X-Patchwork-Id: 193525 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=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT 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 6D692C34026 for ; Tue, 18 Feb 2020 14:11:19 +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 E326321D56 for ; Tue, 18 Feb 2020 14:11:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=alsa-project.org header.i=@alsa-project.org header.b="gPQOZtC2" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E326321D56 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=intel.com 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 471221676; Tue, 18 Feb 2020 15:10:27 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 471221676 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1582035077; bh=DBrZJ7CbcYIwh8PM3hD85CjWDiNtgf3EFWtqEBgksFw=; h=From:To:Subject:Date:Cc:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From; b=gPQOZtC2Pa8PCRf5rcKHoA3kolxqpL8AQXr2V12bOGyGmRvMdTyEZbwEYqI8UCa1q pLDt+ijKG5aAIMjnbVnx6JoGmAqFqc6CYsqr0C84MvSxxbKnRjuMhrUvwXQblKPphR p0eE14M8bOBgeSRyF6TFWdqIj10jiJsOSgRGdXRc= Received: from alsa1.perex.cz (localhost.localdomain [127.0.0.1]) by alsa1.perex.cz (Postfix) with ESMTP id CFF7CF80145; Tue, 18 Feb 2020 15:10:26 +0100 (CET) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 3E913F80148; Tue, 18 Feb 2020 15:10:25 +0100 (CET) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 23984F80135 for ; Tue, 18 Feb 2020 15:10:21 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 23984F80135 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Feb 2020 06:10:19 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,456,1574150400"; d="scan'208";a="258565823" Received: from crojewsk-ctrl.igk.intel.com ([10.102.9.28]) by fmsmga004.fm.intel.com with ESMTP; 18 Feb 2020 06:10:18 -0800 From: Cezary Rojewski To: alsa-devel@alsa-project.org Subject: [PATCH] ASoC: SOF: Intel: Fix stream cleanup on pcm close Date: Tue, 18 Feb 2020 15:10:13 +0100 Message-Id: <20200218141013.7290-1-cezary.rojewski@intel.com> X-Mailer: git-send-email 2.17.1 Cc: lgirdwood@gmail.com, Cezary Rojewski , broonie@kernel.org, tiwai@suse.com, pierre-louis.bossart@linux.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" Field "substream" gets assigned during stream setup in hda_dsp_pcm_hw_params() but it is never cleared afterwards during hda_dsp_pcm_close(). Now, any non-pcm operation e.g.: compress can mistakenly make use of that pointer as it's bypassing all "if (s->substream)" checks. Nulling the pointer during close operation ensures no wild pointers are left behind. Fixes: cdae3b9a47aa ("ASoC: SOF: Intel: Add Intel specific HDA PCM operations") Signed-off-by: Cezary Rojewski --- sound/soc/sof/intel/hda-pcm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/sof/intel/hda-pcm.c b/sound/soc/sof/intel/hda-pcm.c index a46a6baa1c3f..4b3a89cf20e7 100644 --- a/sound/soc/sof/intel/hda-pcm.c +++ b/sound/soc/sof/intel/hda-pcm.c @@ -246,5 +246,6 @@ int hda_dsp_pcm_close(struct snd_sof_dev *sdev, /* unbinding pcm substream to hda stream */ substream->runtime->private_data = NULL; + hstream->substream = NULL; return 0; }