Message ID | 1577823863-3303-3-git-send-email-jonathan.derrick@intel.com |
---|---|
State | New |
Headers | show |
Series | Clean up VMD DMA Map Ops | expand |
On 1/1/20 4:24 AM, Jon Derrick wrote: > 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> This fix looks reasonable to me. Acked-by: Lu Baolu <baolu.lu@linux.intel.com> Best regards, baolu > --- > 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) >
On 1/1/20 4:24 AM, Jon Derrick wrote: > 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> Queued for v5.6. Best regards, baolu
On Sun, Jan 12, 2020 at 09:36:56AM +0800, Lu Baolu wrote: > On 1/1/20 4:24 AM, Jon Derrick wrote: > > 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> > > Queued for v5.6. No need to do so, I sent it upstream with the last pile of iommu fixes. Thanks, Joerg
On 1/13/20 8:20 PM, Joerg Roedel wrote: > On Sun, Jan 12, 2020 at 09:36:56AM +0800, Lu Baolu wrote: >> On 1/1/20 4:24 AM, Jon Derrick wrote: >>> 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> >> >> Queued for v5.6. > > No need to do so, I sent it upstream with the last pile of iommu fixes. Got it. Thank you! Best regards, baolu
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)
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(-)