vfio/spapr_tce: Fix incorrect tce_iommu_group memory free
authorAlexey Kardashevskiy <aik@ozlabs.ru>
Mon, 19 Aug 2019 01:51:17 +0000 (11:51 +1000)
committerAlex Williamson <alex.williamson@redhat.com>
Mon, 19 Aug 2019 19:32:52 +0000 (13:32 -0600)
commit78becab98b8f2f7d22e615675d1a701a67a885af
tree12142bdcaffc284c83567a6bef9f9c7c25987270
parentd1abaeb3be7b5fa6d7a1fbbd2e14e3310005c4c1
vfio/spapr_tce: Fix incorrect tce_iommu_group memory free

The @tcegrp variable is used in 1) a loop over attached groups
2) it stores a pointer to a newly allocated tce_iommu_group if 1) found
nothing. However the error handler does not distinguish how we got there
and incorrectly releases memory for a found+incompatible group.

This fixes it by adding another error handling case.

Fixes: 0bd971676e68 ("powerpc/powernv/npu: Add compound IOMMU groups")
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: Paul Mackerras <paulus@ozlabs.org>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/vfio/vfio_iommu_spapr_tce.c