[PATCH] hyperv: prevent potential NULL dereference

Oleg Sviridov posted 1 patch 1 year, 9 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20240503092659.654077-1-oleg.sviridov@red-soft.ru
src/hyperv/hyperv_driver.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] hyperv: prevent potential NULL dereference
Posted by Oleg Sviridov 1 year, 9 months ago
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 <oleg.sviridov@red-soft.ru>
---
 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.44.0
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org
Re: [PATCH] hyperv: prevent potential NULL dereference
Posted by Kristina Hanicova 1 year, 9 months ago
On Fri, May 3, 2024 at 11:43 AM Oleg Sviridov <oleg.sviridov@red-soft.ru>
wrote:

> 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 <oleg.sviridov@red-soft.ru>
> ---
>  src/hyperv/hyperv_driver.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>

 Reviewed-by: Kristína Hanicová <khanicov@redhat.com>
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org
Re: [PATCH] hyperv: prevent potential NULL dereference
Posted by Ján Tomko 1 year, 9 months ago
On a Friday in 2024, Kristina Hanicova wrote:
>On Fri, May 3, 2024 at 11:43 AM Oleg Sviridov <oleg.sviridov@red-soft.ru>
>wrote:
>
>> Return value of a function 'virDomainChrDefNew' is dereferenced
>> at hyperv_driver.c without checking for NULL, which can lead to
>> NULL dereference immediatly after.

*immediately

>>
>> Found by Linux Verification Center (linuxtesting.org) with SVACE.
>>
>> Signed-off-by: Oleg Sviridov <oleg.sviridov@red-soft.ru>
>> ---
>>  src/hyperv/hyperv_driver.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>
> Reviewed-by: Kristína Hanicová <khanicov@redhat.com>

Now pushed.

Jano
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-leave@lists.libvirt.org