vfio/pci: Fix potential memory leak in vfio_msi_cap_len

Free allocated vdev->msi_perm in error path.

Signed-off-by: Li Qiang <liq3ea@gmail.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
This commit is contained in:
Li Qiang 2018-09-25 13:01:27 -06:00 committed by Alex Williamson
parent 6bf4ca7fbc
commit 30ea32ab19
1 changed files with 3 additions and 1 deletions

View File

@ -1180,8 +1180,10 @@ static int vfio_msi_cap_len(struct vfio_pci_device *vdev, u8 pos)
return -ENOMEM;
ret = init_pci_cap_msi_perm(vdev->msi_perm, len, flags);
if (ret)
if (ret) {
kfree(vdev->msi_perm);
return ret;
}
return len;
}