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 45E17482C5; Mon, 11 Dec 2023 14:01:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="u8Jgf2/E" Received: by smtp.kernel.org (Postfix) with ESMTPSA id E86BFC433C7; Mon, 11 Dec 2023 14:01:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1702303296; bh=NWkzHG+K3m4lF693Vqo99ninvDgUxvdob817lE/wkuA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u8Jgf2/EpuXMOK9MeSlLFKrvuHaFFdcsOockCbay3A0OY2H+iiYXjtRfSurZuYKOz WRTMHjrPw1W26QVmOEbxBkyX0wpGPXUO1jIOoOlhPBqFVe9VInEfzr5A28tC4WfsUK zgKqm31cf3UkyiAK8hmK835DTiBtq5/hAaxMKikdooOBsbnICwzhBlRBp8jpM8DQ+X p3VUFR+Whn4nqNzHko36E6jQ4LDtaHLEmFelmD7OAppJeygHAOZqfVunc5H6BePzj3 ik7x0violXs08DxQnB+Y6wimIlV+L7PzXI2JH/tqECzsnTTdMNDoHyrNopsUxuMMj5 QLx7OLP3inEtw== 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 5.10 04/16] ASoC: Intel: Skylake: mem leak in skl register function Date: Mon, 11 Dec 2023 09:00:28 -0500 Message-ID: <20231211140116.391986-4-sashal@kernel.org> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231211140116.391986-1-sashal@kernel.org> References: <20231211140116.391986-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: stable@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 5.10.203 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 c7e76111f68b7..935c871abdaa6 100644 --- a/sound/soc/intel/skylake/skl-pcm.c +++ b/sound/soc/intel/skylake/skl-pcm.c @@ -1477,6 +1477,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; } @@ -1489,8 +1490,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