]> git.ipfire.org Git - thirdparty/libvirt.git/commit
node_device_conf: Don't prealloc @vfs in virNodeDeviceGetPCISRIOVCaps()
authorMichal Privoznik <mprivozn@redhat.com>
Sun, 12 Sep 2021 06:28:48 +0000 (08:28 +0200)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 15 Sep 2021 06:41:06 +0000 (08:41 +0200)
commit757ed5b09ca8a8d9da7fee44e6006a07b4cdb4ac
tree1f7ad998d931bf7ec18ab6c71c6e15ce2fe7d737
parentbdd3dfba1518567475630140135b4ae69c3820f0
node_device_conf: Don't prealloc @vfs in virNodeDeviceGetPCISRIOVCaps()

The array of virtual functions @vfs in
virNodeDeviceGetPCISRIOVCaps() is allocated twice: the first time
during its declaration and the second time inside
virPCIGetVirtualFunctions() which leads to a memleak:

==16691== 1,128 bytes in 47 blocks are definitely lost in loss record 1,771 of 1,803
==16691==    at 0x4844CC1: calloc (vg_replace_malloc.c:1117)
==16691==    by 0x4E50070: g_malloc0 (in /usr/lib64/libglib-2.0.so.0.6800.3)
==16691==    by 0x4A7B034: virNodeDeviceGetPCISRIOVCaps (node_device_conf.c:2649)
==16691==    by 0x4A7B5E2: virNodeDeviceGetPCIDynamicCaps (node_device_conf.c:2762)
==16691==    by 0xA7F6E18: udevProcessPCI (node_device_udev.c:418)

Fixes: c97518d9b833a607f29b9bb02e3fbe74c011c088
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
src/conf/node_device_conf.c