From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 940DD1B96D; Thu, 18 Jan 2024 10:54:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705575243; cv=none; b=qdr2BroGncvQA69prMKFp8MI76weZngW+vxfI99cksd17WLVIoAyr96PkhSv8OgUgrCLowAloGiZqs3WUSV2SgIc4ftlSbSdcKSlAV/AGgrGrEzQcneTY3dz8Hfx8BR9vRz77EXiEf0SFFLFjau1TYwN1e1Umt55vpkFL9aFjmQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705575243; c=relaxed/simple; bh=uCtpTRnj7QHuYxrr3223rambwjiTYnfJbzcZ7Vyd75U=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:User-Agent:X-stable: X-Patchwork-Hint:MIME-Version:Content-Type: Content-Transfer-Encoding; b=c9HD4BB+3c5dJiILE5ms3cDMO80KExqbqIdTIDr+Mn+xfLngn5ACVk2/JAOufs5riop6c697ORoT7z3liu8CFbcq0Ljyvj4vJTxo3B9N5Rfgp6TwwQkM9PVcXgRexDJ+eO0h+5py+sOz8MR4YUX2GJxCCuGUuTLOANPeLaZHUWo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=xs9qt82L; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="xs9qt82L" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1710AC433F1; Thu, 18 Jan 2024 10:54:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1705575243; bh=uCtpTRnj7QHuYxrr3223rambwjiTYnfJbzcZ7Vyd75U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xs9qt82L6NK+Sr0hIMf35IIq6Q4u6rzk26MscCpjTrQVPmQ1pYM8Y7hVmgW6+TkAQ GW9HJseTYDtpWmHhDIEs2f2yMHSQnk/9TeZRGhHScm1ltnOvFiLagCFfGaDss159EP 9/OjWxktR6c29Vjwl3pMfJXwW5geOHPBpR8af6oU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Kamil Duljas , =?UTF-8?q?Amadeusz=20S=C5=82awi=C5=84ski?= , Mark Brown , Sasha Levin Subject: [PATCH 6.6 034/150] ASoC: Intel: Skylake: mem leak in skl register function Date: Thu, 18 Jan 2024 11:47:36 +0100 Message-ID: <20240118104321.671904444@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240118104320.029537060@linuxfoundation.org> References: <20240118104320.029537060@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kamil Duljas [ Upstream commit f8ba14b780273fd290ddf7ee0d7d7decb44cc365 ] skl_platform_register() uses krealloc. When krealloc is fail, then previous memory is not freed. The leak is also when soc component registration failed. Signed-off-by: Kamil Duljas Reviewed-by: Amadeusz Sławiński Link: https://lore.kernel.org/r/20231116224112.2209-2-kamil.duljas@gmail.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/intel/skylake/skl-pcm.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sound/soc/intel/skylake/skl-pcm.c b/sound/soc/intel/skylake/skl-pcm.c index 29a03ee3d7f7..c602275fcf71 100644 --- a/sound/soc/intel/skylake/skl-pcm.c +++ b/sound/soc/intel/skylake/skl-pcm.c @@ -1473,6 +1473,7 @@ int skl_platform_register(struct device *dev) dais = krealloc(skl->dais, sizeof(skl_fe_dai) + sizeof(skl_platform_dai), GFP_KERNEL); if (!dais) { + kfree(skl->dais); ret = -ENOMEM; goto err; } @@ -1485,8 +1486,10 @@ int skl_platform_register(struct device *dev) ret = devm_snd_soc_register_component(dev, &skl_component, skl->dais, num_dais); - if (ret) + if (ret) { + kfree(skl->dais); dev_err(dev, "soc component registration failed %d\n", ret); + } err: return ret; } -- 2.43.0