summaryrefslogtreecommitdiff
path: root/samples
diff options
context:
space:
mode:
authorColin Ian King <colin.king@canonical.com>2021-06-22 19:37:10 +0100
committerAlex Williamson <alex.williamson@redhat.com>2021-06-24 13:31:28 -0600
commit0af5160edb87b1868eba514422d3991628a018f8 (patch)
treeeedc52ba9a1f75838a01ef6a3845ed080987127c /samples
parentc7396f2eac2bf9d767d9cf49bd26224fbb894aaf (diff)
downloadlwn-0af5160edb87b1868eba514422d3991628a018f8.tar.gz
lwn-0af5160edb87b1868eba514422d3991628a018f8.zip
vfio/mdpy: Fix memory leak of object mdev_state->vconfig
In the case where the call to vfio_register_group_dev fails the error return path kfree's mdev_state but not mdev_state->vconfig. Fix this by kfree'ing mdev_state->vconfig before returning. Addresses-Coverity: ("Resource leak") Fixes: 437e41368c01 ("vfio/mdpy: Convert to use vfio_register_group_dev()") Signed-off-by: Colin Ian King <colin.king@canonical.com> Link: https://lore.kernel.org/r/20210622183710.28954-1-colin.king@canonical.com Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Diffstat (limited to 'samples')
-rw-r--r--samples/vfio-mdev/mdpy.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/samples/vfio-mdev/mdpy.c b/samples/vfio-mdev/mdpy.c
index 7e9c9df0f05b..393c9df6f6a0 100644
--- a/samples/vfio-mdev/mdpy.c
+++ b/samples/vfio-mdev/mdpy.c
@@ -261,6 +261,7 @@ static int mdpy_probe(struct mdev_device *mdev)
ret = vfio_register_group_dev(&mdev_state->vdev);
if (ret) {
+ kfree(mdev_state->vconfig);
kfree(mdev_state);
return ret;
}