[PATCH 3/3] iommu/fsl: Fix the error condition during iommu group

From: Varun Sethi
Date: Tue Jun 24 2014 - 14:31:10 EST


Earlier PTR_ERR was being returned even if group was set to null.
Now, we explicitly set an ERR_PTR value in case the group pointer is
NULL.

Signed-off-by: Varun Sethi <Varun.Sethi@xxxxxxxxxxxxx>
---
drivers/iommu/fsl_pamu_domain.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/iommu/fsl_pamu_domain.c b/drivers/iommu/fsl_pamu_domain.c
index 54060d1..af47648 100644
--- a/drivers/iommu/fsl_pamu_domain.c
+++ b/drivers/iommu/fsl_pamu_domain.c
@@ -1037,12 +1037,15 @@ root_bus:
group = get_shared_pci_device_group(pdev);
}

+ if (!group)
+ group = ERR_PTR(-ENODEV);
+
return group;
}

static int fsl_pamu_add_device(struct device *dev)
{
- struct iommu_group *group = NULL;
+ struct iommu_group *group = ERR_PTR(-ENODEV);
struct pci_dev *pdev;
const u32 *prop;
int ret, len;
@@ -1065,7 +1068,7 @@ static int fsl_pamu_add_device(struct device *dev)
group = get_device_iommu_group(dev);
}

- if (!group || IS_ERR(group))
+ if (IS_ERR(group))
return PTR_ERR(group);

ret = iommu_group_add_device(group, dev);
--
1.7.9.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/