Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp3121483rwb; Mon, 15 Aug 2022 18:39:02 -0700 (PDT) X-Google-Smtp-Source: AA6agR4QQtyIpUH4kAjc4w1CfaAN/YC12pRdA+9CEorak3z7AAGbl/+sZqxJuz/pkHpzMxGhnDiy X-Received: by 2002:a63:4826:0:b0:427:7f43:bcd9 with SMTP id v38-20020a634826000000b004277f43bcd9mr10018395pga.254.1660613942737; Mon, 15 Aug 2022 18:39:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660613942; cv=none; d=google.com; s=arc-20160816; b=AuAsAnA14E2egTo0F2yuNPpZUThy3kAALWirPZQukmviuFRFoodN1Rtsw0s7m27Z/z WmXHyqSqq4zTkgIrON4YnOTtS/2vATMsEWDgHDLDruvC34Dp4miYbKxtNjtYQ4cG42JO htUlu70Bqm0NLpce/QkzavGqic9oYsWbcGYXRET2bHCHGpq0/Zz3gBxJTcPhvLacgBGl dA9frBr3YfT1g4mVQ5jKHxjxZFbjyqnBqXDgWlHuq1yb0gPe8UNrxMsRabvcWaWOXKOe SLkAJbC9sTsZzTjglZuJJ47/qrwvFcXGAHsAUmYJ293c49YuMZKh5gc2s6gG+dZvmx6v lR3A== 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=Xxqsforq0DIWlmbFq3/Ehqp9jycJPxQH/NGLsXfMPXM=; b=kEt/LA/oRnUoG1unfTFNkZgsbas4p9GfaaNZa2pIMghIoGMJg+6BYt2IAa+olrtS5Z n5mdLJuk20R8pu1krNVVunsV4YZwEIBvizWBJ/5gLE/e8I3zsNOWD+eGzGdo0HYoSQ+J BqmXxXdZ9b98aPgZdyGB3TNFMGPDDO8+QRlatrNkb83hwIvDnVDBk28bx55GvPdd6Bo/ r4bV5HYu5R1IZeOdWAEmpfupTUc8d6z1rY5TANEjnxMUeVgMkmL9u9VIv9INIjAbcUjs Pcbbhj1gUE1zJEJEhd0WwQLFGeMJDBVC7Q1RSVyIZNqKUyUoJgA3RFUlf4y3Qa0Fzard CQEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dRVeXsjp; 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 r83-20020a632b56000000b00419be2b2b2fsi12571262pgr.735.2022.08.15.18.38.52; Mon, 15 Aug 2022 18:39:02 -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=dRVeXsjp; 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 S242377AbiHPAxR (ORCPT + 99 others); Mon, 15 Aug 2022 20:53:17 -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-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 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 = NULL; return ret; } -- 2.35.1