From nobody Fri May 17 21:34:34 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1675842374; cv=none; d=zohomail.com; s=zohoarc; b=gIsakyjPLlV7RBghbw5nAVDXUEOwUXahVau0ozVu+KwMLghYAS5NkqcyyFc/DhAmDfbnMU4i3q/s3HK2b5s3x54TsnohHhd1DG7oDlAeKjF22DFcNryXYbW2bNvHVkMSTroicoy6KzMx/VCDC2IsOq1IfbjHdwyyv4ygxIgduJk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675842374; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Sender:Subject:To; bh=IbUFcRUjy3dw0E9qfTLxnXzWRXvabOuUYuYwkmlB/A4=; b=L7nwxw0depwueY/BJsBhS0BeVobAUBBO4ct9Y29+SAX3CyceVv8d53U6yjRVaKOJYqiygvQaFXFSXwgOLggaqyDYeZrA6oc1wBsW1fAmqK0oUq91gF8qH/7AxH8B/ryiYi81g/6FdtXMJFmL0e6iFbMkRgcG51eiTwpdmCbGEOI= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675842374529161.77786702639798; Tue, 7 Feb 2023 23:46:14 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pPf97-0005rR-Jt; Wed, 08 Feb 2023 02:45:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pPf93-0005r6-Ad for qemu-devel@nongnu.org; Wed, 08 Feb 2023 02:45:33 -0500 Received: from szxga01-in.huawei.com ([45.249.212.187]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pPf90-0000zv-SZ for qemu-devel@nongnu.org; Wed, 08 Feb 2023 02:45:33 -0500 Received: from kwepemm600007.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4PBX6H5j99zmWqs; Wed, 8 Feb 2023 15:43:03 +0800 (CST) Received: from DESKTOP-6NKE0BC.china.huawei.com (10.174.185.210) by kwepemm600007.china.huawei.com (7.193.23.208) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 8 Feb 2023 15:45:15 +0800 To: Markus Armbruster , "open list:All patches CC here" CC: , , , Kunkun Jiang Subject: [PATCH] qmp: Add error proofing for query-acpi-ospm-status Date: Wed, 8 Feb 2023 15:45:01 +0800 Message-ID: <20230208074501.1225-1-jiangkunkun@huawei.com> X-Mailer: git-send-email 2.26.2.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.174.185.210] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600007.china.huawei.com (7.193.23.208) X-CFilter-Loop: Reflected Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=45.249.212.187; envelope-from=jiangkunkun@huawei.com; helo=szxga01-in.huawei.com X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Kunkun Jiang From: Kunkun Jiang via Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1675842376017100001 Content-Type: text/plain; charset="utf-8" The ACPI device may not implement the ospm_status callback. Executing qmp "query-acpi-ospm-status" will cause segmentation fault. Add error proofing add log to avoid such serious consequences. Signed-off-by: Kunkun Jiang --- monitor/qmp-cmds.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index bf22a8c5a6..7652613635 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -229,7 +229,12 @@ ACPIOSTInfoList *qmp_query_acpi_ospm_status(Error **er= rp) AcpiDeviceIfClass *adevc =3D ACPI_DEVICE_IF_GET_CLASS(obj); AcpiDeviceIf *adev =3D ACPI_DEVICE_IF(obj); =20 - adevc->ospm_status(adev, &prev); + if (adevc->ospm_status) { + adevc->ospm_status(adev, &prev); + } else { + error_setg(errp, "command is not supported, " + "ACPI device missing ospm_status callback"); + } } else { error_setg(errp, "command is not supported, missing ACPI device"); } --=20 2.33.0