vfio-ccw: plug memory leak while getting region info
authorCornelia Huck <cohuck@redhat.com>
Mon, 28 Sep 2020 10:17:01 +0000 (12:17 +0200)
committerCornelia Huck <cohuck@redhat.com>
Fri, 2 Oct 2020 11:52:49 +0000 (13:52 +0200)
commitc8726f7b24be9384a148f3dc212036398193441c
tree021c78e8c12ef7275a60abe4366efb86b8a0d29a
parent20d143e2cab8b597bbdb7a15f123d9704fa8db18
vfio-ccw: plug memory leak while getting region info

vfio_get_dev_region_info() unconditionally allocates memory
for a passed-in vfio_region_info structure (and does not re-use
an already allocated structure). Therefore, we have to free
the structure we pass to that function in vfio_ccw_get_region()
for every region we successfully obtained information for.

Fixes: 8fadea24de4e ("vfio-ccw: support async command subregion")
Fixes: 46ea3841edaf ("vfio-ccw: Add support for the schib region")
Fixes: f030532f2ad6 ("vfio-ccw: Add support for the CRW region and IRQ")
Reported-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20200928101701.13540-1-cohuck@redhat.com>
hw/vfio/ccw.c