Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1440153rwb; Mon, 7 Nov 2022 01:28:24 -0800 (PST) X-Google-Smtp-Source: AMsMyM6PE3183SyMNtKIvMQNkw+Cl5TUkDGG+G16uFNFGr+mqrYqD0xCpAPEqjh5wUccddeBG6s4 X-Received: by 2002:a05:6402:428a:b0:42e:8f7e:1638 with SMTP id g10-20020a056402428a00b0042e8f7e1638mr49366231edc.228.1667813303951; Mon, 07 Nov 2022 01:28:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1667813303; cv=none; d=google.com; s=arc-20160816; b=gySwgMg/gFR7xMegOXGIT3lwp+b1pxBMWUwcvBGzzHoiZUKtMD5f8Y38tHFkHYBxJo KGrD4JIQMc7R+xV5S+i6sGvOUe4WgCaacBkjjfpm/wt+m+TKh3f+ORT+nzHbnMbLZN1X mAuzpKfwEUqIOBJWz4xb7zOB8vzn2OHopjCtDPyU/zbtTZu34KBSMFf8ewiCcC65lZaT ImRnYRTGG9HVGldAlh98NzqPrC8s4XTq7DKaYo6Xh2TsJ4qx3xpiEsobAher1usflelv 1vuZ3vc6Fe0SlQ1768fG+HP77dNyIxlY3I+PQAFb5rqa0IjCJ4rIhgEt3WWx91ZdaYWC N2tA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=bFh7HEgIxwXWf/otIsspRKWbYc6H6BJSqBBOpH026jk=; b=HJzotUm+WgTt4I9Br9Js+OVLNhRvpDjNJDk47Mtq+aqpBiiyHiQWsjZAJVRjFT0dVz T1TTsFYNFaKgVueqUKKU8g7t13KNxnYfyHj4ygL2oJsIQQ4zm7FgkNoG8k1FSjDL2YgS 6wdLZJTb+iEtMm/sxn8Oz/HFhHoqxKyWW+I7L/G4cL0RBQGiH/TDrpKq7vcN9NkOKUvK WegKHG5PxrBoyszKxY5colG0a4TMCpy/1MXuSKBAts/gUncms1wsoF7gf5W+KL9bEuJD i0KWhSn6huOrI6XVzvld4fk5y07B/PYMNgjoksLSxVBfcIvGprNRrwCxHe95Gg2obwq1 PFiw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x8-20020a170906710800b007123952b00dsi6417143ejj.100.2022.11.07.01.28.01; Mon, 07 Nov 2022 01:28:23 -0800 (PST) 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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230449AbiKGJZd (ORCPT + 95 others); Mon, 7 Nov 2022 04:25:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231848AbiKGJZM (ORCPT ); Mon, 7 Nov 2022 04:25:12 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58E3E186F3; Mon, 7 Nov 2022 01:24:39 -0800 (PST) Received: from dggpemm500024.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4N5QhC1nf6zpSsj; Mon, 7 Nov 2022 17:20:59 +0800 (CST) Received: from dggpemm500013.china.huawei.com (7.185.36.172) by dggpemm500024.china.huawei.com (7.185.36.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 7 Nov 2022 17:24:37 +0800 Received: from ubuntu1804.huawei.com (10.67.175.36) by dggpemm500013.china.huawei.com (7.185.36.172) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Mon, 7 Nov 2022 17:24:37 +0800 From: Chen Zhongjin To: , , CC: , , , Subject: [PATCH] ACPICA: Fix pop_walk_state called after walk_state is deleted Date: Mon, 7 Nov 2022 17:21:22 +0800 Message-ID: <20221107092122.110204-1-chenzhongjin@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.175.36] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To dggpemm500013.china.huawei.com (7.185.36.172) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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 In the previous fix patch acpi_ds_pop_walk_state() is called after acpi_ds_delete_walk_state() in cleanup, so the problem is not fixed because it is acpi_ds_pop_walk_state(NULL) called actually. Also, when acpi_ds_create_walk_state() failed and next_walk_state is NULL, it pops the normal walk_state_list and make the memory leaked. Check if next_walk_state is NULL, and do pop_walk_state() before it is deleted. Fixes: 539663bb068f ("ACPICA: Fix use-after-free in acpi_ps_parse_aml()") Signed-off-by: Chen Zhongjin --- drivers/acpi/acpica/dsmethod.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/acpica/dsmethod.c b/drivers/acpi/acpica/dsmethod.c index 19da7fc73186..cb15c66d5aac 100644 --- a/drivers/acpi/acpica/dsmethod.c +++ b/drivers/acpi/acpica/dsmethod.c @@ -580,8 +580,9 @@ acpi_ds_call_control_method(struct acpi_thread_state *thread, /* On error, we must terminate the method properly */ acpi_ds_terminate_control_method(obj_desc, next_walk_state); + if (next_walk_state) + acpi_ds_pop_walk_state(thread); acpi_ds_delete_walk_state(next_walk_state); - acpi_ds_pop_walk_state(thread); return_ACPI_STATUS(status); } -- 2.17.1