Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3025736rwb; Mon, 15 Aug 2022 16:23:45 -0700 (PDT) X-Google-Smtp-Source: AA6agR7g2FpNoX17xQBZlWbc+gbAN8l+q8srfi3akn2TIkN1czr9h11j1zRt1ldOQnLM0chuw6eR X-Received: by 2002:a17:907:3da7:b0:730:cae5:7f7d with SMTP id he39-20020a1709073da700b00730cae57f7dmr11643742ejc.711.1660605825391; Mon, 15 Aug 2022 16:23:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660605825; cv=none; d=google.com; s=arc-20160816; b=TMjHR2kyxffrB2Hlelhcl8b3YnKnEGVVvLR/mW7cZJtVlj+0dsazexapYv00RalIUd cFuuIm1SV4lJ1YspU8Ys/zUCz3tOFiwuNFfJqpP/YwB1GtM1toCaaiS5WOum0qKeYcul +uKUy5kP4M24m82H07L+FV0tBCgK0iR2yY3rhkzOoht0buzoYzQbxUmeu9nc66o8Fdr0 mQVeh6MfTPpSXgOXdqQ6oYYv2SMHILFXBDZ/CvbEsO7jYQbr/ZMaxLy5QeP1LNQVHOBA cAXT7yBOVGbOZQ95iFYXeVYmaBiB0v5ZWqUdFM/qTdVloOLTJ2Y71LaH3Ek2mO4o5Gpu tYqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=e+B3+GGQyp64oPd5DdLlPnLA5wzYln11XmsCjGjQziM=; b=w/SjpggMEhwffj5Xvfaqeqqwa+5sMGcSSSB6KayWztaIsVqhXc5A8ANuBu2tYOI60N pb6EmNdwbh7gtnBX6HW/ragDZsXpygvWPs8fyTszQfrRpSPXNEM28bfUghONHtIBOIu0 EgpfBZsrthSg5pn562sxG4ykH0kPxpxS9/zow2tcEdlgKInLECjkY2OMMy9XFovV3a8z EH2AS11ouq7R2ULWe1EGaqKl+9SXRBMoJr6YzjhfNUyWY1cU+Z2zh7ZBje9EUP64S7Ps YjoB+KlJqYR38OMBH6EKPdRBKJg9PD8ofB3FBJS2J4Yq0X/pE4GTyhcyBO91eJZP86EM Ef8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=P8yHJUQ4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y5-20020a056402358500b0043c4912e226si10039476edc.568.2022.08.15.16.23.20; Mon, 15 Aug 2022 16:23:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=P8yHJUQ4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351421AbiHOWmN (ORCPT + 99 others); Mon, 15 Aug 2022 18:42:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1350928AbiHOWhV (ORCPT ); Mon, 15 Aug 2022 18:37:21 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B29C2DE8; Mon, 15 Aug 2022 12:50:40 -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 ams.source.kernel.org (Postfix) with ESMTPS id 0E773B81154; Mon, 15 Aug 2022 19:50:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5254AC433D7; Mon, 15 Aug 2022 19:50:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1660593003; bh=tkqliisyWlw//YEyiwGGxb+HGB3tuKHQvqGhfE8nTOA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P8yHJUQ4ZNrSQrP6BCP9wS6eQM3e1EuMZT1FzTMSQLLWHgFiTYuPlhGEd7sHFQ98u uzMbsxU62Npbbk5X3hRgWpuhoqUC/JkOsdE8GzCeVcXW7rGd0lxNfMmEnkt3WGDH+U pYDWASujksCo7oC/3uO8PmrC8H6/7WijkfMBSk/U= 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.18 0878/1095] ASoC: SOF: ipc3-topology: Prevent double freeing of ipc_control_data via load_bytes Date: Mon, 15 Aug 2022 20:04:37 +0200 Message-Id: <20220815180505.688938280@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220815180429.240518113@linuxfoundation.org> References: <20220815180429.240518113@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 agnostic") 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 80fb82ece38d..74c230fbcf68 100644 --- a/sound/soc/sof/ipc3-topology.c +++ b/sound/soc/sof/ipc3-topology.c @@ -1629,6 +1629,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 = NULL; return ret; } -- 2.35.1