From a42f11c40b27a06e4abed01682c3796405d5947d Mon Sep 17 00:00:00 2001 From: Oleg Sviridov Date: Fri, 3 May 2024 12:26:51 +0300 Subject: [PATCH] hyperv: prevent potential NULL dereference MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Return value of a function 'virDomainChrDefNew' is dereferenced at hyperv_driver.c without checking for NULL, which can lead to NULL dereference immediately after. Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Oleg Sviridov Reviewed-by: Kristína Hanicová Signed-off-by: Ján Tomko --- 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_ResourceAllocationSettingData continue; } - serial = virDomainChrDefNew(NULL); + if (!(serial = virDomainChrDefNew(NULL))) + return -1; serial->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; serial->source->type = VIR_DOMAIN_CHR_TYPE_PIPE; -- 2.39.5