diff options
author | Suman Anna <s-anna@ti.com> | 2014-02-28 15:42:33 -0500 |
---|---|---|
committer | Joerg Roedel <joro@8bytes.org> | 2014-03-04 11:01:24 -0500 |
commit | 7ee08b9ef2e942a5477f02a71947b933eb4101d2 (patch) | |
tree | 7767a05b651743b41a1c6884591419eca09d4af4 | |
parent | f129b3dfb5517c91295da9fe0d2e584d8da25518 (diff) |
iommu/omap: Fix error return paths in omap_iommu_attach()
There are couple of issues with the error return paths in
omap_iommu_attach():
1. omap_iommu_attach() returns NULL or ERR_PTR in case of error,
but omap_iommu_attach_dev() only checks for IS_ERR. Thus a NULL
return value (in case driver_find_device fails) will cause the
kernel to panic when omap_iommu_attach_dev() dereferences the
pointer.
2. A try_module_get() failure returns a valid success value as
returned from iommu_enable().
Both the above issues have been fixed up to return the proper
ERR_PTR.
Signed-off-by: Florian Vaussard <florian.vaussard@epfl.ch>
Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Joerg Roedel <joro@8bytes.org>
-rw-r--r-- | drivers/iommu/omap-iommu.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c index fff2ffdc26f4..647e4ba0df95 100644 --- a/drivers/iommu/omap-iommu.c +++ b/drivers/iommu/omap-iommu.c | |||
@@ -863,7 +863,7 @@ static int device_match_by_alias(struct device *dev, void *data) | |||
863 | **/ | 863 | **/ |
864 | static struct omap_iommu *omap_iommu_attach(const char *name, u32 *iopgd) | 864 | static struct omap_iommu *omap_iommu_attach(const char *name, u32 *iopgd) |
865 | { | 865 | { |
866 | int err = -ENOMEM; | 866 | int err; |
867 | struct device *dev; | 867 | struct device *dev; |
868 | struct omap_iommu *obj; | 868 | struct omap_iommu *obj; |
869 | 869 | ||
@@ -871,7 +871,7 @@ static struct omap_iommu *omap_iommu_attach(const char *name, u32 *iopgd) | |||
871 | (void *)name, | 871 | (void *)name, |
872 | device_match_by_alias); | 872 | device_match_by_alias); |
873 | if (!dev) | 873 | if (!dev) |
874 | return NULL; | 874 | return ERR_PTR(-ENODEV); |
875 | 875 | ||
876 | obj = to_iommu(dev); | 876 | obj = to_iommu(dev); |
877 | 877 | ||
@@ -890,8 +890,10 @@ static struct omap_iommu *omap_iommu_attach(const char *name, u32 *iopgd) | |||
890 | goto err_enable; | 890 | goto err_enable; |
891 | flush_iotlb_all(obj); | 891 | flush_iotlb_all(obj); |
892 | 892 | ||
893 | if (!try_module_get(obj->owner)) | 893 | if (!try_module_get(obj->owner)) { |
894 | err = -ENODEV; | ||
894 | goto err_module; | 895 | goto err_module; |
896 | } | ||
895 | 897 | ||
896 | spin_unlock(&obj->iommu_lock); | 898 | spin_unlock(&obj->iommu_lock); |
897 | 899 | ||