OSDN Git Service

Merge tag 'powerpc-4.12-1' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc...
[uclinux-h8/linux.git] / drivers / vfio / vfio_iommu_spapr_tce.c
index 8031d3a..63112c3 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);
 
@@ -1335,8 +1340,16 @@ static int tce_iommu_attach_group(void *iommu_data,
 
        if (!table_group->ops || !table_group->ops->take_ownership ||
                        !table_group->ops->release_ownership) {
+               if (container->v2) {
+                       ret = -EPERM;
+                       goto unlock_exit;
+               }
                ret = tce_iommu_take_ownership(container, table_group);
        } else {
+               if (!container->v2) {
+                       ret = -EPERM;
+                       goto unlock_exit;
+               }
                ret = tce_iommu_take_ownership_ddw(container, table_group);
                if (!tce_groups_attached(container) && !container->tables[0])
                        container->def_window_pending = true;