diff options
author | Alexey Kardashevskiy <aik@ozlabs.ru> | 2017-03-27 14:23:40 +1100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-03-22 09:17:51 +0100 |
commit | bab8ac1b274eb835a6ac33501dbd010fc0262822 (patch) | |
tree | 2a4ea3368d03974710d8b90a6402665d91140f15 /drivers/vfio | |
parent | 5d7601dcb29d4b51cc32da4a744533f524a6fc8a (diff) |
vfio/spapr_tce: Check kzalloc() return when preregistering memory
[ Upstream commit 3393af24b665cb0aea7353b05e522b03ab1e7d73 ]
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>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/vfio')
-rw-r--r-- | drivers/vfio/vfio_iommu_spapr_tce.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/vfio/vfio_iommu_spapr_tce.c b/drivers/vfio/vfio_iommu_spapr_tce.c index 87ad0d72d8a9..70c748a5fbcc 100644 --- a/drivers/vfio/vfio_iommu_spapr_tce.c +++ b/drivers/vfio/vfio_iommu_spapr_tce.c @@ -195,6 +195,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); |