Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp338862pxj; Thu, 20 May 2021 10:28:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxyQs6ICXqX59/OFnl8Wun7+l6T2ZB2SoNwNr7XiUdULIK1VWhdU0CDbnh1EQJenpBCZGAC X-Received: by 2002:a05:6402:44:: with SMTP id f4mr6154495edu.364.1621531698746; Thu, 20 May 2021 10:28:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621531698; cv=none; d=google.com; s=arc-20160816; b=wR8Q8D8Om0AzbpIpZKstsNcqQxxDJ8dzpXxEA9r773B8390FLFBOtbQa/yEZIehXRB CUtXXLkD7f03ZSvCpVXi+rYBSRMOPbQDTotXYfKNgTZB6og4NbePhyIXzFtlT6EU64Po GPAWojKUU2lzkltIi6VsJYn5fpDGUWdqw2gtnSH4KlKwuzRkBVurzsT05jnPzlBHtUsl P0uQq4Sdu16X/H7ICNPoTpwxztg8ILOzVLCd8vVA83ToOSgaYhlz+dRVbJZyvFcByL1J bwJb1gdkZAEG1cT9kDJGF3ihtFoVNOl50qarN76Pe0rZ8P63GfL2G7kYWLU3VxrJwtCE g6Bg== 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=Iv5QCDoL+HKTWgBOPa77tlbA01vPKJ+gZA2EXoqu7O4=; b=K6IRKZ1tgtm3R8GcI48E7SBurF16L6igMT4LRJXWgGgktm1OgsRzWnBkWeirAiokAf AEX/Bgt6ERds5JEMqXV27psTCtE2IWf4HltfSQy+SZ3IVxaUAYboKRdSpvP3Vnd3mV5C 0tWbRY6PdpngM4DkNB5+0fcXkvZcqrC5qmS4Uuzci6WLdJlfuvP9GW3fFTdM7le5QkW3 QQAGFitaj5O7Hjy07xkORNpRwHXjlljy31xDMG1Nuo6XtKWLCNArwuXWgtf/C6uyoJ6w q9J0k93ZWuYyVRv4VARTS52ul96Goxha2d0B4CoCbd1Q9rXKi+LMaeRUQSUDwqIgZZTl AqXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EtmiEsw4; 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 a20si1527404edj.72.2021.05.20.10.27.53; Thu, 20 May 2021 10:28:18 -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; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=EtmiEsw4; 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 S231911AbhETJ4a (ORCPT + 99 others); Thu, 20 May 2021 05:56:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:52388 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234469AbhETJwq (ORCPT ); Thu, 20 May 2021 05:52:46 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 6101461582; Thu, 20 May 2021 09:36:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621503380; bh=4ePEs0WA8a5cVcLLL7zTb9hlbn2sOvi0LDvS2EKiG/0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=EtmiEsw44j0C96wx7sGssmtlPcW/AFLBNv5USwXEtHUkLHzH1eITvnfvg7FzybGwr miZFLawczhX8foUGnh6Fso9HxacGzeooiX0ZeR7bW5Xc5/QoX3RvTUeG2Gxwb/lwWY O5BaCTB/8yiJ1LrhTf7O0jxhjd/vGEwpTHDkBxzU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Rander Wang , Keyon Jie , Guennadi Liakhovetski , Pierre-Louis Bossart , Bard Liao , Vinod Koul , Sasha Levin Subject: [PATCH 4.19 196/425] soundwire: stream: fix memory leak in stream config error path Date: Thu, 20 May 2021 11:19:25 +0200 Message-Id: <20210520092137.861833156@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210520092131.308959589@linuxfoundation.org> References: <20210520092131.308959589@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Rander Wang [ Upstream commit 48f17f96a81763c7c8bf5500460a359b9939359f ] When stream config is failed, master runtime will release all slave runtime in the slave_rt_list, but slave runtime is not added to the list at this time. This patch frees slave runtime in the config error path to fix the memory leak. Fixes: 89e590535f32 ("soundwire: Add support for SoundWire stream management") Signed-off-by: Rander Wang Reviewed-by: Keyon Jie Reviewed-by: Guennadi Liakhovetski Reviewed-by: Pierre-Louis Bossart Signed-off-by: Bard Liao Link: https://lore.kernel.org/r/20210331004610.12242-1-yung-chuan.liao@linux.intel.com Signed-off-by: Vinod Koul Signed-off-by: Sasha Levin --- drivers/soundwire/stream.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/soundwire/stream.c b/drivers/soundwire/stream.c index 907a548645b7..42bc701e2304 100644 --- a/drivers/soundwire/stream.c +++ b/drivers/soundwire/stream.c @@ -1182,8 +1182,16 @@ int sdw_stream_add_slave(struct sdw_slave *slave, } ret = sdw_config_stream(&slave->dev, stream, stream_config, true); - if (ret) + if (ret) { + /* + * sdw_release_master_stream will release s_rt in slave_rt_list in + * stream_error case, but s_rt is only added to slave_rt_list + * when sdw_config_stream is successful, so free s_rt explicitly + * when sdw_config_stream is failed. + */ + kfree(s_rt); goto stream_error; + } list_add_tail(&s_rt->m_rt_node, &m_rt->slave_rt_list); -- 2.30.2