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 BD18F4776B; Mon, 11 Dec 2023 13:55:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Rqr/yh+U" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B45DC433C9; Mon, 11 Dec 2023 13:55:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702302921; bh=A76cpvz3m9NeTeVfKmY8UFhCPcRnCAzK8Hp3DUieAFU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rqr/yh+UIRLHArywKHCx3FVZX7tikYemhuFUQV9cxZY4bnZ4kzoc419sMdB6/Gy3B qTaAR0drstzW+th6WiCNX3YTfD8IlgfrWboqPigNq2udkv8cmKKwwUTn6T+mfqB4mj SWutB2fjcoNU0KfPlBeE2g0cfI8MPEU72/fzZQzZ/kFs1ImWm8uRpuzaRc5TlsC8+P RqzI6ngPREuOYZ3G/mwTPebMGwY4gTfN6W2J/YcwIEeKpabjWUnlnZLahbQl3YFkOr 3h7yp45REs79wIlvi8lTV407gqRRXiUYS4UthJ/wuSvtIoWCqwFVoephtKfyibilHt uwaJh4tq3cqUg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Kamil Duljas , =?UTF-8?q?Amadeusz=20S=C5=82awi=C5=84ski?= , Mark Brown , Sasha Levin , cezary.rojewski@intel.com, pierre-louis.bossart@linux.intel.com, liam.r.girdwood@linux.intel.com, peter.ujfalusi@linux.intel.com, yung-chuan.liao@linux.intel.com, ranjani.sridharan@linux.intel.com, kai.vehmanen@linux.intel.com, perex@perex.cz, tiwai@suse.com, kuninori.morimoto.gx@renesas.com, suhui@nfschina.com, zhangyiqun@phytium.com.cn, alsa-devel@alsa-project.org, linux-sound@vger.kernel.org Subject: [PATCH AUTOSEL 6.1 07/29] ASoC: Intel: Skylake: mem leak in skl register function Date: Mon, 11 Dec 2023 08:53:51 -0500 Message-ID: <20231211135457.381397-7-sashal@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231211135457.381397-1-sashal@kernel.org> References: <20231211135457.381397-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-sound@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 6.1.66 Content-Transfer-Encoding: 8bit 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 7ef0041075130..adee4be2dea71 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.42.0