]> git.ipfire.org Git - thirdparty/qemu.git/commit
xen-block: Avoid leaks on new error path
authorAnthony PERARD <anthony.perard@citrix.com>
Tue, 4 Jul 2023 17:18:19 +0000 (18:18 +0100)
committerMichael Tokarev <mjt@tls.msk.ru>
Wed, 2 Aug 2023 14:21:39 +0000 (17:21 +0300)
commitf120e4742c3783ca296f2e83b6f2feb05b39712d
tree7d12535792d86229d2414be7d6753a1dd4c5c330
parente4aae3f8190948ab75a49f4650630eedbfb28789
xen-block: Avoid leaks on new error path

Commit 189829399070 ("xen-block: Use specific blockdev driver")
introduced a new error path, without taking care of allocated
resources.

So only allocate the qdicts after the error check, and free both
`filename` and `driver` when we are about to return and thus taking
care of both success and error path.

Coverity only spotted the leak of qdicts (*_layer variables).

Reported-by: Peter Maydell <peter.maydell@linaro.org>
Fixes: Coverity CID 1508722, 1398649
Fixes: 189829399070 ("xen-block: Use specific blockdev driver")
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Paul Durrant <paul@xen.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Message-Id: <20230704171819.42564-1-anthony.perard@citrix.com>
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
(cherry picked from commit aa36243514a777f76c8b8a19b1f8a71f27ec6c78)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
hw/block/xen-block.c