From nobody Mon Sep 29 21:09:04 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 088B7C00140 for ; Tue, 16 Aug 2022 00:53:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243113AbiHPAxS (ORCPT ); Mon, 15 Aug 2022 20:53:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56650 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233161AbiHPAoE (ORCPT ); Mon, 15 Aug 2022 20:44:04 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C700319230C; Mon, 15 Aug 2022 13:40:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 635F061185; Mon, 15 Aug 2022 20:40:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A39CC433D6; Mon, 15 Aug 2022 20:40:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660596027; bh=77vapIcyjRpAWS+nM1j1G1Guba+2OS7XdW3xVb0Phes=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dRVeXsjpSoaMFXFUI7r+lQcDLJhsYYmU82vOxXpvxXu6Cc/1Pg0HLhyp5ogPMIB9x chh8DJzTEf5lAtXeXUz48NPlttjHP2Cnfw9k4+NHHtgfkz5k9LBuS3/ZdkqtYoQlgw ++mc3bLHAlHRfG8IvR4/9wz2iZFiiwSn6SPm+kYM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Seppo Ingalsuo , Peter Ujfalusi , Ranjani Sridharan , Pierre-Louis Bossart , Mark Brown , Sasha Levin Subject: [PATCH 5.19 0951/1157] ASoC: SOF: ipc3-topology: Prevent double freeing of ipc_control_data via load_bytes Date: Mon, 15 Aug 2022 20:05:07 +0200 Message-Id: <20220815180517.627610692@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180439.416659447@linuxfoundation.org> References: <20220815180439.416659447@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Peter Ujfalusi [ Upstream commit d5bd47f3ca124058a8e87eae4508afeda2132611 ] We have sanity checks for byte controls and if any of the fail the locally allocated scontrol->ipc_control_data is freed up, but not set to NULL. On a rollback path of the error the higher level code will also try to free the scontrol->ipc_control_data which will eventually going to lead to memory corruption as double freeing memory is not a good thing. Fixes: b5cee8feb1d4 ("ASoC: SOF: topology: Make control parsing IPC agnosti= c") Reported-by: Seppo Ingalsuo Signed-off-by: Peter Ujfalusi Reviewed-by: Seppo Ingalsuo Reviewed-by: Ranjani Sridharan Reviewed-by: Pierre-Louis Bossart Link: https://lore.kernel.org/r/20220712130103.31514-1-peter.ujfalusi@linux= .intel.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- sound/soc/sof/ipc3-topology.c | 1 + 1 file changed, 1 insertion(+) diff --git a/sound/soc/sof/ipc3-topology.c b/sound/soc/sof/ipc3-topology.c index 10740c55294d..e97f50d5bcba 100644 --- a/sound/soc/sof/ipc3-topology.c +++ b/sound/soc/sof/ipc3-topology.c @@ -1628,6 +1628,7 @@ static int sof_ipc3_control_load_bytes(struct snd_sof= _dev *sdev, struct snd_sof_ return 0; err: kfree(scontrol->ipc_control_data); + scontrol->ipc_control_data =3D NULL; return ret; } =20 --=20 2.35.1