iommu/msm: Fix error handling in msm_iommu_unmap()
authorJoerg Roedel <joerg.roedel@amd.com>
Thu, 26 Jan 2012 17:25:37 +0000 (18:25 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 13 Feb 2012 19:17:01 +0000 (11:17 -0800)
commit 05df1f3c2afaef5672627f2b7095f0d4c4dbc3a0 upstream.

Error handling in msm_iommu_unmap() is broken. On some error
conditions retval is set to a non-zero value which causes
the function to return 'len' at the end. This hides the
error from the user. Zero should be returned in those error
cases.

Cc: David Brown <davidb@codeaurora.org>
Cc: Stepan Moskovchenko <stepanm@codeaurora.org>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Acked-by: David Brown <davidb@codeaurora.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/iommu/msm_iommu.c

index 5865dd2..a4d134d 100644 (file)
@@ -481,23 +481,19 @@ static int msm_iommu_unmap(struct iommu_domain *domain, unsigned long va,
 
        priv = domain->priv;
 
-       if (!priv) {
-               ret = -ENODEV;
+       if (!priv)
                goto fail;
-       }
 
        fl_table = priv->pgtable;
 
        if (len != SZ_16M && len != SZ_1M &&
            len != SZ_64K && len != SZ_4K) {
                pr_debug("Bad length: %d\n", len);
-               ret = -EINVAL;
                goto fail;
        }
 
        if (!fl_table) {
                pr_debug("Null page table\n");
-               ret = -EINVAL;
                goto fail;
        }
 
@@ -506,7 +502,6 @@ static int msm_iommu_unmap(struct iommu_domain *domain, unsigned long va,
 
        if (*fl_pte == 0) {
                pr_debug("First level PTE is 0\n");
-               ret = -ENODEV;
                goto fail;
        }