From: Alexey Kardashevskiy Date: Mon, 27 Mar 2017 03:23:40 +0000 (+1100) Subject: vfio/spapr_tce: Check kzalloc() return when preregistering memory X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3393af24b665cb0aea7353b05e522b03ab1e7d73;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git vfio/spapr_tce: Check kzalloc() return when preregistering memory 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 Reviewed-by: David Gibson Signed-off-by: Alex Williamson --- diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c index a7d811524092..78dca1aa6410 100644 --- a/drivers/vfio/vfio_iommu_spapr_tce.c +++ b/drivers/vfio/vfio_iommu_spapr_tce.c @@ -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);