Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp3497299pxa; Sun, 9 Aug 2020 02:00:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMLirM0s8H2xSvnG0OrClyUNTLEBC2l9GB4T3fBh53Bq/UIJw0a4j27FhZNJebdnG3G7T7 X-Received: by 2002:aa7:c251:: with SMTP id y17mr16703157edo.13.1596963626198; Sun, 09 Aug 2020 02:00:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596963626; cv=none; d=google.com; s=arc-20160816; b=u469gHSN4NCt/IOSwd+mi+2v0FSs13Qlqwb4+Xthn/YJus4ctnMsHXVEsZmzFQOfxk 3Pgq5H4Sk01b7H8VAJAfTuSNz2smsD5lb5FMzVkCpYTgFay7ghVB1MlN+TpLQ4oB89Y7 Rk84yR2LF136b36FOPWwRZDcQAZoN6Y7zHefUwd4RQaGHiJyH7scXfHWMgK2kAp5Xz29 WuTCC4X9g+l2P6gNHXXBv54yCT4vYMSCL4blH5eMEyO38pvf5FKoqndWrFGxu4Dsl3I0 l4XSFQUQRMgmq1LEQcXRhTqFc0ovBr/Vul9bnC92z1+YcIrKVpKjCQgvVS3cSHBeqH+p cfpg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=xRsj1TmmacGA9HUVqHYtQWuQpLm81xqWZbSkVZ1AVIk=; b=tPHasV499tiHnB1BpomdVyZLTRHKwZlnx52+qyXa6hVAxj+EtxS33QU9TIficHf76j OZdQe1iZAsB9fWIFrlBDq/4smN3QrOJqI9jk02HScsUTmbx0wMsGofB0SXQiFZL8CGWa yWC7oAjfewJ4pybAjls1gnsKynaDoM4I/zd2nSwqY8/98gz1XNPfwPaHJpbirfnNXbiA S4PlCnNgjpIwNt0UOZ/pmitk3av3UaHXWqj8i+twnCsPmk8wM+wE9vyJ32VWYeaBSsx5 wTGLZeCLBmmz2JxB9hxP/0OUYT7BmSqOWvk77G5/wkP0PnzGi14gNzX3/MA+qvdMOKv1 ghRw== ARC-Authentication-Results: i=1; mx.google.com; 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 se13si8577110ejb.718.2020.08.09.02.00.03; Sun, 09 Aug 2020 02:00:26 -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; 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 S1726250AbgHII51 (ORCPT + 99 others); Sun, 9 Aug 2020 04:57:27 -0400 Received: from spam.zju.edu.cn ([61.164.42.155]:24856 "EHLO zju.edu.cn" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725710AbgHII50 (ORCPT ); Sun, 9 Aug 2020 04:57:26 -0400 Received: from localhost.localdomain (unknown [210.32.144.186]) by mail-app4 (Coremail) with SMTP id cS_KCgBXz3pYui9fFsnCAA--.57403S4; Sun, 09 Aug 2020 16:56:59 +0800 (CST) From: Dinghao Liu To: dinghao.liu@zju.edu.cn, kjlu@umn.edu Cc: Cezary Rojewski , Pierre-Louis Bossart , Liam Girdwood , Jie Yang , Mark Brown , Jaroslav Kysela , Takashi Iwai , Kuninori Morimoto , Ranjani Sridharan , "Subhransu S. Prusty" , Vinod Koul , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: [PATCH] ASoC: intel: Fix memleak in sst_media_open Date: Sun, 9 Aug 2020 16:56:52 +0800 Message-Id: <20200809085654.16483-1-dinghao.liu@zju.edu.cn> X-Mailer: git-send-email 2.17.1 X-CM-TRANSID: cS_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a73UjIFyTuYvjfUeHUDDUUUU X-CM-SenderInfo: qrrzjiaqtzq6lmxovvfxof0/1tbiAgsFBlZdtPe8fwADsC Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When power_up_sst() fails, stream needs to be freed just like when try_module_get() fails. However, current code is returning directly and ends up leaking memory. Fixes: 0121327c1a68b ("ASoC: Intel: mfld-pcm: add control for powering up/down dsp") Signed-off-by: Dinghao Liu --- sound/soc/intel/atom/sst-mfld-platform-pcm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sound/soc/intel/atom/sst-mfld-platform-pcm.c b/sound/soc/intel/atom/sst-mfld-platform-pcm.c index 49b9f18472bc..79fedf9e3da1 100644 --- a/sound/soc/intel/atom/sst-mfld-platform-pcm.c +++ b/sound/soc/intel/atom/sst-mfld-platform-pcm.c @@ -330,8 +330,10 @@ static int sst_media_open(struct snd_pcm_substream *substream, runtime->private_data = stream; ret_val = power_up_sst(stream); - if (ret_val < 0) + if (ret_val < 0) { + kfree(stream); return ret_val; + } /* Make sure, that the period size is always even */ snd_pcm_hw_constraint_step(substream->runtime, 0, -- 2.17.1