vfio/iommufd: Fix memory leak
commit57001144628db65ef9b7dbbfb759101212696d6a
authorCédric Le Goater <clg@redhat.com>
Thu, 14 Mar 2024 08:22:38 +0000 (14 09:22 +0100)
committerCédric Le Goater <clg@redhat.com>
Tue, 19 Mar 2024 10:56:37 +0000 (19 11:56 +0100)
treee57d75b4a119da6e7903d39aa752f5bb6b8b6fa8
parent4511400fb78e72d4d9916ed60e04f4e99e594f65
vfio/iommufd: Fix memory leak

Coverity reported a memory leak on variable 'contents' in routine
iommufd_cdev_getfd(). Use g_autofree variables to simplify the exit
path and get rid of g_free() calls.

Cc: Eric Auger <eric.auger@redhat.com>
Cc: Yi Liu <yi.l.liu@intel.com>
Fixes: CID 1540007
Fixes: 5ee3dc7af785 ("vfio/iommufd: Implement the iommufd backend")
Suggested-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
hw/vfio/iommufd.c