]> git.proxmox.com Git - mirror_qemu.git/commit
xen-block: stop leaking memory in xen_block_drive_create()
authorPaul Durrant <paul.durrant@citrix.com>
Tue, 19 Feb 2019 16:34:40 +0000 (16:34 +0000)
committerAnthony PERARD <anthony.perard@citrix.com>
Thu, 28 Feb 2019 17:21:12 +0000 (17:21 +0000)
commit156ac94463b42b0b9beea263af9866dfcd3683e0
tree463ca22c5c0ef9f7d609fb0e4b3f862ce0f58750
parent2ae23f0ecf002203977b7337219e2413abd656ec
xen-block: stop leaking memory in xen_block_drive_create()

The locally allocated QDict-s need to be freed. ('file_layer' will be
freed implicitly since it is added as an object to 'driver_layer').

Spotted by Coverity: CID 1398649

While in the neighbourhood free 'driver' and 'filename' as soon as they are
added to the QDicts. Freeing after the 'done' label doesn't make that much
sense as, if the error path jumps to that label, the values would be NULL
anyway.

This patch also makes that more obvious by taking the error path if
'params' is NULL and then asserting that both driver and filename are
non-NULL in the normal path.

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
Message-Id: <20190219163440.15702-1-paul.durrant@citrix.com>
Acked-by: Anthony PERARD <anthony.perard@citrix.com>
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
hw/block/xen-block.c