No checks, dereferencing possible
Quoted 6 lines · Миронов Сергей Владимирович
No checks, dereferencing possible.
Return value of a function 'virDomainChrSourceDefNew' is dereferenced at
qemu_command.cwithout checking for NULL, but it is usually checked for this function.
This description here doesn't make sense. You are checking the presence of 'privateData' in 'virDomainVideoDef'.
Quoted 18 lines
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes 1f85f0967b ("ci: jobs.sh: Add back '--no-suite syntax-check --print-errorlogs'")Signed-off-by Sergey Mironov <[email protected]>---
src/qemu/qemu_command.c| 2 ++1 file changed, 2 insertions(+)src/qemu/qemu_command.c +0
-0
src/qemu/qemu_command.c qemuBuildVideoCommandLine(virCommand *cmd, · line 4702
Quoted 5 lines
src/qemu/qemu_command.c +2
-0@@ -4698,6 +4698,8 @@ qemuBuildVideoCommandLine(virCommand *cmd, g_autofree char *name = g_strdup_printf("%s-vhost-user", video->info.alias);qemuDomainChrSourcePrivate *chrsrcpriv =QEMU_DOMAIN_CHR_SOURCE_PRIVATE (chrsrc); +if (chrsrc ==NULL ) +return -1 ;
This addition doesn't make sense as it's dead code. The private data is always allocated and checked that it's non-NULL in the qemu driver via the callback in virDomainVideoDefNew.
Do you have a call trace that would prove me otherwise?
PATCH 1/1 No checks, dereferencing possible
No checks, dereferencing possible.
Return value of a function 'virDomainChrSourceDefNew' is dereferenced at qemu_command.c without checking for NULL, but it is usually checked for this function.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
---src/qemu/qemu_command.c | 2 ++
1 file changed, 2 insertions(+)
src/qemu/qemu_command.c +2 -1
@@ -4698,6 +4698,8 @@ qemuBuildVideoCommandLine(virCommand *cmd, g_autofree char *name = g_strdup_printf("%s-vhost-user", video->info.alias);qemuDomainChrSourcePrivate *chrsrcpriv =QEMU_DOMAIN_CHR_SOURCE_PRIVATE (chrsrc); +if (chrsrc ==NULL ) +return -1 ; chrsrc->type =VIR_DOMAIN_CHR_TYPE_UNIX ; chrsrcpriv->directfd =qemuFDPassDirectNew (name, &videopriv->vhost_user_fd); --
2.31.1
Quoted 32 lines · Peter Krempa
Quoted 6 lines · Миронов Сергей Владимирович
No checks, dereferencing possible.
Return value of a function 'virDomainChrSourceDefNew' is dereferenced at
qemu_command.cwithout checking for NULL, but it is usually checked for this function.This description here doesn't make sense. You are checking the presence of 'privateData' in 'virDomainVideoDef'.
Quoted 21 lines
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes 1f85f0967b ("ci: jobs.sh: Add back '--no-suite syntax-check --print-errorlogs'")Signed-off-by Sergey Mironov <[email protected]>---
src/qemu/qemu_command.c| 2 ++1 file changed, 2 insertions(+)src/qemu/qemu_command.c +0
-0@@ -4698,6 +4698,8 @@ qemuBuildVideoCommandLine(virCommand *cmd, g_autofree char *name = g_strdup_printf("%s-vhost-user", video->info.alias);qemuDomainChrSourcePrivate *chrsrcpriv =QEMU_DOMAIN_CHR_SOURCE_PRIVATE (chrsrc);
Quoted 6 lines
src/qemu/qemu_command.c qemuBuildVideoCommandLine(virCommand *cmd, · line 4702
Quoted 2 lines
src/qemu/qemu_command.c +2
-0+if (chrsrc ==NULL ) +return -1 ;This addition doesn't make sense as it's dead code. The private data is always allocated and checked that it's non-NULL in the qemu driver via the callback in virDomainVideoDefNew.
This is checking the result of virDomainChrSourceDefNew(), which can fail as virDomainChrSourceDefInitialize() can fail if virClassNew() fails its sanity checks.
The check is too late though, as we de-referenced chrsrc in the line above when we accessed the private data.
Quoted 3 lines
Do you have a call trace that would prove me otherwise?
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|