From nobody Mon Feb 9 12:41:53 2026 Delivered-To: importer@patchew.org Received-SPF: none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; spf=none (zohomail.com: 8.43.85.245 is neither permitted nor denied by domain of lists.libvirt.org) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=red-soft.ru Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1714729440968460.5896060205416; Fri, 3 May 2024 02:44:00 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id DA5091D33; Fri, 3 May 2024 05:43:59 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 584211D42; Fri, 3 May 2024 05:39:37 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 476E61C79; Fri, 3 May 2024 05:35:35 -0400 (EDT) Received: from gw.red-soft.ru (red-soft.ru [188.246.186.2]) by lists.libvirt.org (Postfix) with ESMTP id 450C919F4 for ; Fri, 3 May 2024 05:35:34 -0400 (EDT) Received: from localhost.biz (unknown [10.81.100.51]) by gw.red-soft.ru (Postfix) with ESMTPA id EBEE43E2083; Fri, 3 May 2024 12:27:24 +0300 (MSK) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=0.5 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_VALIDITY_RPBL,SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.4 X-Greylist: delayed 487 seconds by postgrey-1.37 at lists.libvirt.org; Fri, 03 May 2024 05:35:34 EDT From: Oleg Sviridov To: devel@lists.libvirt.org Subject: [PATCH] hyperv: prevent potential NULL dereference Date: Fri, 3 May 2024 12:26:51 +0300 Message-ID: <20240503092659.654077-1-oleg.sviridov@red-soft.ru> X-Mailer: git-send-email 2.44.0 MIME-Version: 1.0 X-KLMS-Rule-ID: 1 X-KLMS-Message-Action: clean X-KLMS-AntiSpam-Lua-Profiles: 185033 [May 03 2024] X-KLMS-AntiSpam-Version: 6.1.0.4 X-KLMS-AntiSpam-Envelope-From: oleg.sviridov@red-soft.ru X-KLMS-AntiSpam-Rate: 0 X-KLMS-AntiSpam-Status: not_detected X-KLMS-AntiSpam-Method: none X-KLMS-AntiSpam-Auth: dkim=none X-KLMS-AntiSpam-Info: LuaCore: 19 0.3.19 07c7fa124d1a1dc9662cdc5aace418c06ae99d2b, {Tracking_from_domain_doesnt_match_to}, localhost.biz:7.1.1;127.0.0.199:7.1.2;d41d8cd98f00b204e9800998ecf8427e.com:7.1.1;red-soft.ru:7.1.1, FromAlignment: s X-MS-Exchange-Organization-SCL: -1 X-KLMS-AntiSpam-Interceptor-Info: scan successful X-KLMS-AntiPhishing: Clean, bases: 2024/05/03 07:46:00 X-KLMS-AntiVirus: Kaspersky Security for Linux Mail Server, version 8.0.3.30, bases: 2024/05/03 04:26:00 #25076703 X-KLMS-AntiVirus-Status: Clean, skipped X-MailFrom: oleg.sviridov@red-soft.ru X-Mailman-Rule-Hits: nonmember-moderation X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0 Message-ID-Hash: 3H76JSF6KZD7DOUIXLZORDIC2FQC6OUI X-Message-ID-Hash: 3H76JSF6KZD7DOUIXLZORDIC2FQC6OUI X-Mailman-Approved-At: Fri, 03 May 2024 09:39:21 -0400 CC: Oleg Sviridov X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1714729441310100001 Return value of a function 'virDomainChrDefNew' is dereferenced at hyperv_driver.c without checking for NULL, which can lead to NULL dereference immediatly after. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Oleg Sviridov --- src/hyperv/hyperv_driver.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 414274fdfd..7580c6a06c 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -1534,7 +1534,8 @@ hypervDomainDefParseSerial(virDomainDef *def, Msvm_Re= sourceAllocationSettingData continue; } =20 - serial =3D virDomainChrDefNew(NULL); + if (!(serial =3D virDomainChrDefNew(NULL))) + return -1; =20 serial->deviceType =3D VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; serial->source->type =3D VIR_DOMAIN_CHR_TYPE_PIPE; --=20 2.44.0 _______________________________________________ Devel mailing list -- devel@lists.libvirt.org To unsubscribe send an email to devel-leave@lists.libvirt.org