]> git.ipfire.org Git - thirdparty/libvirt.git/commit
bhyve: Avoid memleak in bhyveParsePassthru()
authorMichal Privoznik <mprivozn@redhat.com>
Mon, 2 Feb 2026 14:36:37 +0000 (15:36 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 4 Feb 2026 07:29:38 +0000 (08:29 +0100)
commit1779a8600f1899c03ecd8bdcb772a37be2b3e345
treef8336257b92367fe046f9d1d89b40c94ffa41e3a
parentbf34b90bb4e39b3a2fd22a5531f5ea5a95681015
bhyve: Avoid memleak in bhyveParsePassthru()

The aim of bhyveParsePassthru() is to parse PCI address from
bhyve command line. The PCI address might be of a form
bus:slot:function or bus/slot/function. If the former isn't found
the latter is parsed (both using g_strsplit()). But after the
first call, g_strsplit() just returns a string list containing
but the whole input duplicated. Therefore, calling plain g_free()
is not enough, the array must be freed too.

6 bytes in 1 blocks are definitely lost in loss record 1 of 325
   at 0x4863224: malloc (vg_replace_malloc.c:451)
   by 0x4EC6562: g_malloc (in /usr/local/lib/libglib-2.0.so.0.8400.4)
   by 0x4EE28D9: g_strsplit (in /usr/local/lib/libglib-2.0.so.0.8400.4)
   by 0x4011297: bhyveParsePassthru (bhyve_parse_command.c:699)
   by 0x4010082: bhyveParseBhyvePCIArg (bhyve_parse_command.c:800)
   by 0x400EE14: bhyveParseBhyveCommandLine (bhyve_parse_command.c:862)
   by 0x400DF9C: bhyveParseCommandLineString (bhyve_parse_command.c:1058)
   by 0x4008CA0: testCompareXMLToArgvFiles (bhyveargv2xmltest.c:39)
   by 0x4008B29: testCompareXMLToArgvHelper (bhyveargv2xmltest.c:105)
   by 0x4009288: virTestRun (testutils.c:143)
   by 0x40085AC: mymain (bhyveargv2xmltest.c:164)
   by 0x400B582: virTestMain (testutils.c:913)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
src/bhyve/bhyve_parse_command.c