Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp9113426pxu; Mon, 28 Dec 2020 07:00:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJxOEi32cLL6yyijDNApvT1G525ajJSCRE3VyfrdI9zxo+tI3Q78JMpYIN/EwSxaCvTRFQeS X-Received: by 2002:a17:906:5e0d:: with SMTP id n13mr41281662eju.500.1609167634614; Mon, 28 Dec 2020 07:00:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609167634; cv=none; d=google.com; s=arc-20160816; b=mWc1wgAau+PX4s6t/KMjEfhtv5867ohiHGI1H4OWhHrl0RWf0Cp/mRqC0rCRlwBjce WW01ROxz2mRl+3UQ/oNSb1zt+5G08684x1vXus9wxgJUpGzhhA+Dt8xa2/uVubk2t7Ii fX6ViWDA4iYbcyCPORq2R83W2Cy5oKexusXiwetrhzDCWui3a9BZ7F8tQtyWZ8VCyB+o +QbjbJ8mwNk/CwO2MzJCANTM5zdn6DIs0kNHAGttw5mM6hhffjN8fQZTc8BixcdVkYXc 1BfmGKaZa4NcqnQ/3TTBiMeIOGy+f+JxiuTaSj2ris3qwZ5+M9WFJ2Q8xiYNfcctauTq vluw== 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=MSon8kLqG64bZf3yG9OS6YiZq06y/yEM+p4atf8PzPM=; b=fJBe/6IEdpI6FI0pD4XAxb1j3X6T3asg7FwNo0PprLpWoL+4zZ7pB5EBFPzia0TCTW 1gzxoYnDjbAOwrNQ9PCRaF8vpykTiebSv8y9IK/URb+S8dg93mjQoK4LI/0/IUwb8hu2 Et+d0UjKwAIEXU0/HpQJNmST09kvVUdlVkHt71s08YgzRhIydpnVlUg/CYUNWGUmEapP UP1B13WjaoZBtt4L6pe5Xx15d7P5L8QXSQiZebdDKZgrQNV8hyZ+pNfaP4qIdTsmWZ3E LcJdqgDZ1FbxYWK3lXNYjYJ30WyWRg9B+Du91boOHYdk18LcJQt3eNd9PZ1YMyrXakfd 2ozg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="XqI2q/TH"; 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 y7si20739745edp.7.2020.12.28.07.00.11; Mon, 28 Dec 2020 07:00:34 -0800 (PST) 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="XqI2q/TH"; 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 S2440672AbgL1OPe (ORCPT + 99 others); Mon, 28 Dec 2020 09:15:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:50548 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2440654AbgL1OPd (ORCPT ); Mon, 28 Dec 2020 09:15:33 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8621D22B2B; Mon, 28 Dec 2020 14:14:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1609164893; bh=EwWYf0l3c77LObBRIzTxn4rOwQxgD5rxQ9U3iVNuaQA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XqI2q/THEqsycNomFW//S+VUHLCuZNYlOmzngxbS5g0XtGrGQDB2Tam2We56j15+h OJXDjfg9T7/oQOUWaDApquvLHfzJWgFpxnqRQtMGRinzdoPys7UrJxN5hmazsRB7j7 anxvyzZAn3z7ZJm7ZnTdC78Ifa1YlZ4Jax4GzM9U= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Vaibhav Agarwal , Wang Hai , Sasha Levin Subject: [PATCH 5.10 336/717] staging: greybus: audio: Fix possible leak free widgets in gbaudio_dapm_free_controls Date: Mon, 28 Dec 2020 13:45:34 +0100 Message-Id: <20201228125037.119719747@linuxfoundation.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201228125020.963311703@linuxfoundation.org> References: <20201228125020.963311703@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: Wang Hai [ Upstream commit e77b259f67ab99f1e22ce895b9b1c637fd5f2d4c ] In gbaudio_dapm_free_controls(), if one of the widgets is not found, an error will be returned directly, which will cause the rest to be unable to be freed, resulting in leak. This patch fixes the bug. If if one of them is not found, just skip and free the others. Fixes: 510e340efe0c ("staging: greybus: audio: Add helper APIs for dynamic audio module") Reported-by: Hulk Robot Reviewed-by: Vaibhav Agarwal Signed-off-by: Wang Hai Link: https://lore.kernel.org/r/20201205103827.31244-1-wanghai38@huawei.com Signed-off-by: Greg Kroah-Hartman Signed-off-by: Sasha Levin --- drivers/staging/greybus/audio_helper.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/greybus/audio_helper.c b/drivers/staging/greybus/audio_helper.c index 237531ba60f30..3011b8abce389 100644 --- a/drivers/staging/greybus/audio_helper.c +++ b/drivers/staging/greybus/audio_helper.c @@ -135,7 +135,8 @@ int gbaudio_dapm_free_controls(struct snd_soc_dapm_context *dapm, if (!w) { dev_err(dapm->dev, "%s: widget not found\n", widget->name); - return -EINVAL; + widget++; + continue; } widget++; #ifdef CONFIG_DEBUG_FS -- 2.27.0