/* Initialise in-memory data structures */
        ret = arm_smmu_init_structures(smmu);
        if (ret)
-               return ret;
+               goto err_free_iopf;
 
        /* Record our private device structure */
        platform_set_drvdata(pdev, smmu);
        /* Reset the device */
        ret = arm_smmu_device_reset(smmu);
        if (ret)
-               return ret;
+               goto err_disable;
 
        /* And we're up. Go go go! */
        ret = iommu_device_sysfs_add(&smmu->iommu, dev, NULL,
                                     "smmu3.%pa", &ioaddr);
        if (ret)
-               return ret;
+               goto err_disable;
 
        ret = iommu_device_register(&smmu->iommu, &arm_smmu_ops, dev);
        if (ret) {
                dev_err(dev, "Failed to register iommu\n");
-               iommu_device_sysfs_remove(&smmu->iommu);
-               return ret;
+               goto err_free_sysfs;
        }
 
        return 0;
+
+err_free_sysfs:
+       iommu_device_sysfs_remove(&smmu->iommu);
+err_disable:
+       arm_smmu_device_disable(smmu);
+err_free_iopf:
+       iopf_queue_free(smmu->evtq.iopf);
+       return ret;
 }
 
 static void arm_smmu_device_remove(struct platform_device *pdev)