From: Jon Derrick <jonathan.derrick@intel.com> To: <iommu@lists.linux-foundation.org>, <linux-pci@vger.kernel.org> Cc: Bjorn Helgaas <helgaas@kernel.org>, Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>, Keith Busch <kbusch@kernel.org>, Joerg Roedel <joro@8bytes.org>, Christoph Hellwig <hch@lst.de>, David Woodhouse <dwmw2@infradead.org>, Lu Baolu <baolu.lu@linux.intel.com>, Jon Derrick <jonathan.derrick@intel.com> Subject: [RFC 2/5] iommu/vt-d: Unlink device if failed to add to group Date: Tue, 31 Dec 2019 13:24:20 -0700 [thread overview] Message-ID: <1577823863-3303-3-git-send-email-jonathan.derrick@intel.com> (raw) In-Reply-To: <1577823863-3303-1-git-send-email-jonathan.derrick@intel.com> If the device fails to be added to the group, make sure to unlink the reference before returning. Signed-off-by: Jon Derrick <jonathan.derrick@intel.com> --- drivers/iommu/intel-iommu.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index b2526a4..978d502 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -5625,8 +5625,10 @@ static int intel_iommu_add_device(struct device *dev) group = iommu_group_get_for_dev(dev); - if (IS_ERR(group)) - return PTR_ERR(group); + if (IS_ERR(group)) { + ret = PTR_ERR(group); + goto unlink; + } iommu_group_put(group); @@ -5652,7 +5654,8 @@ static int intel_iommu_add_device(struct device *dev) if (!get_private_domain_for_dev(dev)) { dev_warn(dev, "Failed to get a private domain.\n"); - return -ENOMEM; + ret = -ENOMEM; + goto unlink; } dev_info(dev, @@ -5667,6 +5670,10 @@ static int intel_iommu_add_device(struct device *dev) } return 0; + +unlink: + iommu_device_unlink(&iommu->iommu, dev); + return ret; } static void intel_iommu_remove_device(struct device *dev) -- 1.8.3.1
WARNING: multiple messages have this Message-ID (diff)
From: Jon Derrick <jonathan.derrick@intel.com> To: <iommu@lists.linux-foundation.org>, <linux-pci@vger.kernel.org> Cc: Bjorn Helgaas <helgaas@kernel.org>, Keith Busch <kbusch@kernel.org>, David Woodhouse <dwmw2@infradead.org>, Christoph Hellwig <hch@lst.de>, Jon Derrick <jonathan.derrick@intel.com> Subject: [RFC 2/5] iommu/vt-d: Unlink device if failed to add to group Date: Tue, 31 Dec 2019 13:24:20 -0700 [thread overview] Message-ID: <1577823863-3303-3-git-send-email-jonathan.derrick@intel.com> (raw) In-Reply-To: <1577823863-3303-1-git-send-email-jonathan.derrick@intel.com> If the device fails to be added to the group, make sure to unlink the reference before returning. Signed-off-by: Jon Derrick <jonathan.derrick@intel.com> --- drivers/iommu/intel-iommu.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index b2526a4..978d502 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c @@ -5625,8 +5625,10 @@ static int intel_iommu_add_device(struct device *dev) group = iommu_group_get_for_dev(dev); - if (IS_ERR(group)) - return PTR_ERR(group); + if (IS_ERR(group)) { + ret = PTR_ERR(group); + goto unlink; + } iommu_group_put(group); @@ -5652,7 +5654,8 @@ static int intel_iommu_add_device(struct device *dev) if (!get_private_domain_for_dev(dev)) { dev_warn(dev, "Failed to get a private domain.\n"); - return -ENOMEM; + ret = -ENOMEM; + goto unlink; } dev_info(dev, @@ -5667,6 +5670,10 @@ static int intel_iommu_add_device(struct device *dev) } return 0; + +unlink: + iommu_device_unlink(&iommu->iommu, dev); + return ret; } static void intel_iommu_remove_device(struct device *dev) -- 1.8.3.1 _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu
next prev parent reply other threads:[~2020-01-01 2:27 UTC|newest] Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-12-31 20:24 [RFC 0/5] Clean up VMD DMA Map Ops Jon Derrick 2019-12-31 20:24 ` Jon Derrick 2019-12-31 20:24 ` [RFC 1/5] iommu: Remove device link to group on failure Jon Derrick 2019-12-31 20:24 ` Jon Derrick 2020-01-01 3:59 ` Lu Baolu 2020-01-01 3:59 ` Lu Baolu 2019-12-31 20:24 ` Jon Derrick [this message] 2019-12-31 20:24 ` [RFC 2/5] iommu/vt-d: Unlink device if failed to add to group Jon Derrick 2020-01-01 4:05 ` Lu Baolu 2020-01-01 4:05 ` Lu Baolu 2020-01-12 1:36 ` Lu Baolu 2020-01-12 1:36 ` Lu Baolu 2020-01-13 12:20 ` Joerg Roedel 2020-01-13 12:20 ` Joerg Roedel 2020-01-14 1:58 ` Lu Baolu 2020-01-14 1:58 ` Lu Baolu 2019-12-31 20:24 ` [RFC 3/5] x86/PCI: Expose VMD's device in pci_sysdata Jon Derrick 2019-12-31 20:24 ` Jon Derrick 2020-01-09 14:33 ` Christoph Hellwig 2020-01-09 14:33 ` Christoph Hellwig 2020-01-09 15:06 ` Derrick, Jonathan 2020-01-09 15:06 ` Derrick, Jonathan 2020-01-09 16:45 ` Derrick, Jonathan 2020-01-09 16:45 ` Derrick, Jonathan 2019-12-31 20:24 ` [RFC 4/5] PCI: vmd: Stop overriding dma_map_ops Jon Derrick 2019-12-31 20:24 ` Jon Derrick 2020-01-03 15:00 ` kbuild test robot 2020-01-04 9:39 ` kbuild test robot 2020-01-09 14:36 ` Christoph Hellwig 2020-01-09 14:36 ` Christoph Hellwig 2020-01-09 15:08 ` Derrick, Jonathan 2020-01-09 15:08 ` Derrick, Jonathan 2019-12-31 20:24 ` [RFC 5/5] x86/PCI: Remove unused X86_DEV_DMA_OPS Jon Derrick 2019-12-31 20:24 ` Jon Derrick 2020-01-09 14:37 ` Christoph Hellwig 2020-01-09 14:37 ` Christoph Hellwig 2020-01-09 15:06 ` Derrick, Jonathan 2020-01-09 15:06 ` Derrick, Jonathan 2020-01-07 13:41 ` [RFC 0/5] Clean up VMD DMA Map Ops Joerg Roedel 2020-01-07 13:41 ` Joerg Roedel
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1577823863-3303-3-git-send-email-jonathan.derrick@intel.com \ --to=jonathan.derrick@intel.com \ --cc=baolu.lu@linux.intel.com \ --cc=dwmw2@infradead.org \ --cc=hch@lst.de \ --cc=helgaas@kernel.org \ --cc=iommu@lists.linux-foundation.org \ --cc=joro@8bytes.org \ --cc=kbusch@kernel.org \ --cc=linux-pci@vger.kernel.org \ --cc=lorenzo.pieralisi@arm.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.