vfio/spapr_tce: Check kzalloc() return when preregistering memory
authorAlexey Kardashevskiy <aik@ozlabs.ru>
Mon, 27 Mar 2017 03:23:40 +0000 (14:23 +1100)
committerAlex Williamson <alex.williamson@redhat.com>
Tue, 11 Apr 2017 19:40:09 +0000 (13:40 -0600)
This adds missing checking for kzalloc() return value.

Fixes: 4b6fad7097f8 ("powerpc/mm/iommu, vfio/spapr: Put pages on VFIO container shutdown")
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/vfio/vfio_iommu_spapr_tce.c

index a7d8115..78dca1a 100644 (file)
@@ -198,6 +198,11 @@ static long tce_iommu_register_pages(struct tce_container *container,
                return ret;
 
        tcemem = kzalloc(sizeof(*tcemem), GFP_KERNEL);
+       if (!tcemem) {
+               mm_iommu_put(container->mm, mem);
+               return -ENOMEM;
+       }
+
        tcemem->mem = mem;
        list_add(&tcemem->next, &container->prereg_list);