Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4593429pxj; Wed, 12 May 2021 08:52:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzV2RusZSO282zlUvol0TIbZ2CaSBY3Ed28hTFtPyt7PxEqS/PBdGqe+0/YRMphkM+mi0R2 X-Received: by 2002:a17:907:62a7:: with SMTP id nd39mr38522349ejc.502.1620834776747; Wed, 12 May 2021 08:52:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620834776; cv=none; d=google.com; s=arc-20160816; b=g/6B41w/G8cNdrJp885cFhXEFfTce8H5WRTVfVq8492cTh4vpocBf+pZKsLiQVJUFs s6MQxwzIDyEQObUXib4sOvjVHu2nh2dXj5Yjh32Ph4WTHbxFTI0B5ai50njul2c3/s6V HxwyRMv1sp2FCIhxe0J2xzA0owNcqfklKn5cgqOWYj9IcpoXBIhYiypm2NKs95Lu8Egg 9X7RYmVXZzkXMt3ALYo++ksxsdTKRWlPdBxYnrYQ8vjqR/3Tuw50yooHgCfs8Jm/eRo8 tdRPIxQpnZlOKdphkQxD0Wp6RhIC/+gEDli4qemc3tX1oK3ADlVH5LFJuoHbUjUDiZOc +e+w== 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=VQN5Ts14/DszWotzZ2a9yFr7182b474+eEk6xz1Xock=; b=MN/Ck3Z41gZIecXM2NwvXJzoDX84VTZtyu7QHq5K5DUIIm1L0Dd/TDDU8XZRHdX36w 6eIQmIqfU1i2pQ6b9Y1WKs/+ynHkzRD7RaUVjo/mjF8FGVF/Fczm3TR9XUVU/8yyGomh 3hcv6cnGsS8wuen0iSvynH38VI8lXyszuYfGiNiWzJlRqxUzY4daXL/AZ/VdW8zs2s8L 4w7JMEXWHPTzM56g9z9H00P/7kSmEmZKcZ4fLa4bXTSUFYvn16yzHLl1xUiUj6Hw+Uf/ T6uhqUl7shipL2o/rHkYrgXJandSlR9VmGP24KHNLHrkHO8/gvusFeMAYPwl5wlKcw7Y WdoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=T3eXdCgR; 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 s13si101384edr.479.2021.05.12.08.52.32; Wed, 12 May 2021 08:52:56 -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=T3eXdCgR; 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 S233717AbhELPwB (ORCPT + 99 others); Wed, 12 May 2021 11:52:01 -0400 Received: from mail.kernel.org ([198.145.29.99]:40900 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234859AbhELPZw (ORCPT ); Wed, 12 May 2021 11:25:52 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 86F72619D0; Wed, 12 May 2021 15:10:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832247; bh=n1ZiqqtT1iykW2ruKwqfJSGv+fpU1zzut2Bj0uNJCTo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=T3eXdCgRVKTBJ0dJoa3Pld8HrlT+5RCu9dE7RtL/9ZA+3t9CKiEJsjkbw1qefJc5n 3/rFJM2SRKU6KEAzYEVYcWOK6Kive54AOzkSRAMUfjXA2a4rgJ7D4EJMQ3+7+gAMay /QpfesQ3nB3rwAuWGWWfLPhnnVTWb2su7LP+meqA= 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 5.10 201/530] soundwire: stream: fix memory leak in stream config error path Date: Wed, 12 May 2021 16:45:11 +0200 Message-Id: <20210512144826.451912642@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@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 1099b5d1262b..a418c3c7001c 100644 --- a/drivers/soundwire/stream.c +++ b/drivers/soundwire/stream.c @@ -1375,8 +1375,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