From mboxrd@z Thu Jan 1 00:00:00 1970 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=-10.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 0919BC32750 for ; Wed, 14 Aug 2019 02:39:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CABEE20665 for ; Wed, 14 Aug 2019 02:39:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565750343; bh=xqS3v1YUYs6IjprirBY5jzrqWlbFrwFG1Nf3A+/Fu00=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=GG7MPcKYTDKPLtzaPVuHNk4jx2z+XvmtTFAJT6T6D7pVH9ZwySelmbc1uOJehg5NJ EOZcHtqp3FXWSf7+Ppw4XCxPxlTxE92Qrz6QclT1fwpkza2CFjwfgtHF4ahCqeMoDa zaKZiqmUwFn3eaYgstrVBIbpuKBjFaOcAllN6ECc= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728236AbfHNCjC (ORCPT ); Tue, 13 Aug 2019 22:39:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:43922 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727566AbfHNCLm (ORCPT ); Tue, 13 Aug 2019 22:11:42 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6CD8D2085A; Wed, 14 Aug 2019 02:11:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1565748701; bh=xqS3v1YUYs6IjprirBY5jzrqWlbFrwFG1Nf3A+/Fu00=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oR11nE1+S/gZZ4sFfETfdqftVJtpv1v66MT5rNRr/jl+1DSJXCt79ofCaIlEtV5Cc AdY1sI89RMWZJg1FmUhc+lzrPyuZg7CoCTabhC4dtKuRrkKAxcvRGHEcOUrspBLiXW kugYLO/xT+CpXHrPrE2AtHQXFYpryGUMTxo/2BhM= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Wenwen Wang , Mark Brown , Sasha Levin Subject: [PATCH AUTOSEL 5.2 029/123] ASoC: dapm: fix a memory leak bug Date: Tue, 13 Aug 2019 22:09:13 -0400 Message-Id: <20190814021047.14828-29-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190814021047.14828-1-sashal@kernel.org> References: <20190814021047.14828-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Wenwen Wang [ Upstream commit 45004d66f2a28d78f543fb2ffbc133e31dc2d162 ] In snd_soc_dapm_new_control_unlocked(), a kernel buffer is allocated in dapm_cnew_widget() to hold the new dapm widget. Then, different actions are taken according to the id of the widget, i.e., 'w->id'. If any failure occurs during this process, snd_soc_dapm_new_control_unlocked() should be terminated by going to the 'request_failed' label. However, the allocated kernel buffer is not freed on this code path, leading to a memory leak bug. To fix the above issue, free the buffer before returning from snd_soc_dapm_new_control_unlocked() through the 'request_failed' label. Signed-off-by: Wenwen Wang Link: https://lore.kernel.org/r/1563803864-2809-1-git-send-email-wang6495@umn.edu Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/soc-dapm.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 835ce1ff188d9..f40adb604c25b 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c @@ -3705,6 +3705,8 @@ snd_soc_dapm_new_control_unlocked(struct snd_soc_dapm_context *dapm, dev_err(dapm->dev, "ASoC: Failed to request %s: %d\n", w->name, ret); + kfree_const(w->sname); + kfree(w); return ERR_PTR(ret); } -- 2.20.1