Skip to content

Commit 0af5160

Browse files
Colin Ian Kingawilliam
authored andcommitted
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: 437e413 ("vfio/mdpy: Convert to use vfio_register_group_dev()") Signed-off-by: Colin Ian King <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alex Williamson <[email protected]>
1 parent c7396f2 commit 0af5160

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

samples/vfio-mdev/mdpy.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ static int mdpy_probe(struct mdev_device *mdev)
261261

262262
ret = vfio_register_group_dev(&mdev_state->vdev);
263263
if (ret) {
264+
kfree(mdev_state->vconfig);
264265
kfree(mdev_state);
265266
return ret;
266267
}

0 commit comments

Comments
 (0)