Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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 <aik@ozlabs.ru>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>

authored by

Alexey Kardashevskiy and committed by
Alex Williamson
3393af24 1282ba7f

+5
+5
drivers/vfio/vfio_iommu_spapr_tce.c
··· 198 198 return ret; 199 199 200 200 tcemem = kzalloc(sizeof(*tcemem), GFP_KERNEL); 201 + if (!tcemem) { 202 + mm_iommu_put(container->mm, mem); 203 + return -ENOMEM; 204 + } 205 + 201 206 tcemem->mem = mem; 202 207 list_add(&tcemem->next, &container->prereg_list); 203 208