hyperv: prevent potential NULL dereference

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 <oleg.sviridov@red-soft.ru>
Reviewed-by: Kristína Hanicová <khanicov@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Oleg Sviridov 2024-05-03 12:26:51 +03:00 committed by Ján Tomko
parent 3146305fd3
commit a42f11c40b
1 changed files with 2 additions and 1 deletions

View File

@ -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;