mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 09:17:52 +03:00
Ensure nodeinfo struct is initialized to zero
When linuxNodeInfoCPUPopulate() method triggered use of an uninitialize value, since it did not initialize the 'sockets' field in the virNodeInfoPtr struct: ==30020== Conditional jump or move depends on uninitialised value(s) ==30020== at 0x5125DBD: linuxNodeInfoCPUPopulate (nodeinfo.c:513) ==30020== by 0x51261A0: nodeGetInfo (nodeinfo.c:884) ==30020== by 0x149B9B10: qemuCapsInit (qemu_capabilities.c:846) ==30020== by 0x14A11B25: qemuCreateCapabilities (qemu_driver.c:424) ==30020== by 0x14A12426: qemuStartup (qemu_driver.c:874) ==30020== by 0x512A7AF: virStateInitialize (libvirt.c:822) ==30020== by 0x40DE04: daemonRunStateInit (libvirtd.c:877) ==30020== by 0x50ADCE5: virThreadHelper (virthreadpthread.c:161) ==30020== by 0x328CA07D14: start_thread (pthread_create.c:308) ==30020== by 0x328C6F246C: clone (clone.S:114) (happened twice) if (socks > nodeinfo->sockets) <--- here nodeinfo->sockets = socks; Rather than doing this for each field, just make the caller memset the entire struct to zero. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
parent
3b35369c0f
commit
83b4137d41
@ -389,11 +389,6 @@ int linuxNodeInfoCPUPopulate(FILE *cpuinfo,
|
||||
char *sysfs_nodedir = NULL;
|
||||
char *sysfs_cpudir = NULL;
|
||||
|
||||
nodeinfo->cpus = 0;
|
||||
nodeinfo->mhz = 0;
|
||||
nodeinfo->cores = 0;
|
||||
nodeinfo->nodes = 0;
|
||||
|
||||
/* Start with parsing CPU clock speed from /proc/cpuinfo */
|
||||
while (fgets(line, sizeof(line), cpuinfo) != NULL) {
|
||||
# if defined(__x86_64__) || \
|
||||
@ -870,6 +865,8 @@ int nodeGetInfo(virConnectPtr conn ATTRIBUTE_UNUSED, virNodeInfoPtr nodeinfo)
|
||||
{
|
||||
virArch hostarch = virArchFromHost();
|
||||
|
||||
memset(nodeinfo, 0, sizeof(*nodeinfo));
|
||||
|
||||
if (virStrcpyStatic(nodeinfo->model, virArchToString(hostarch)) == NULL)
|
||||
return -1;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user