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 2FD30129A63; Tue, 23 Jan 2024 00:12:31 +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=1705968751; cv=none; b=EnqpGrn8UFo0wBEXMAjKE3GQhrvwngI6yeqEDcxvV8NJ+q1BvzQFAXk+JLR3Cl3FmFumfCk8gt5jVl2ZSXwqulVJmsUTN54ILpL9/8gKsOf8nEz7IiQuV/NEJeu/lZGcEQ7Fu6YsYA1gtz6aufDVP6QPc6roVD/zo1g9qV4cSBs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705968751; c=relaxed/simple; bh=j3YkrBhxgGq4VvgZVjEY+HKILJbaskKONVU9FTgqQv4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NNtJ9/LYUti/oasVG+tkqC07vC5tNwKNPHwzFpAVBY/iR3bC9V1ZdkyEfoQJ8qnNX+ZoYgMUKERXv0t44uBvXE+xHvM65eFJ+Ui4sPErb0rZGCOyYNihUv0a0T21eLuNwaWECsnsmMIB5Ar7B0oLDQVZJyPuMbo9GPKzHyyXfk4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=KZllHojW; 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="KZllHojW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D03B6C43390; Tue, 23 Jan 2024 00:12:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1705968751; bh=j3YkrBhxgGq4VvgZVjEY+HKILJbaskKONVU9FTgqQv4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KZllHojWpozGchu99OQkFzo1hXjGbD+kP1ctCYeil207j8hKpbfIf7skCs8mXh4hW kx6OvIM1tHDUaWbLATZLOE8oO0MK722dNiE02vyCXkATd41kSd/pJq1IXdsOHo/UuN fmjtvDCCkv4HhPaWxW3CYqIN3zsM0pngO+yciGpM= 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 5.4 006/194] ASoC: Intel: Skylake: mem leak in skl register function Date: Mon, 22 Jan 2024 15:55:36 -0800 Message-ID: <20240122235719.482863813@linuxfoundation.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240122235719.206965081@linuxfoundation.org> References: <20240122235719.206965081@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore 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 Content-Transfer-Encoding: 8bit 5.4-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 19176ae27274..3256f7c4eb74 100644 --- a/sound/soc/intel/skylake/skl-pcm.c +++ b/sound/soc/intel/skylake/skl-pcm.c @@ -1492,6 +1492,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; } @@ -1504,8 +1505,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