Commit d7cd8fc525c9322ceb1f1de26d7c6201aef9d842

Authored by Joerg Roedel
Committed by Greg Kroah-Hartman
1 parent 61c39c6dcc

iommu/msm: Fix error handling in msm_iommu_unmap()

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>

Showing 1 changed file with 1 additions and 6 deletions Side-by-side Diff

drivers/iommu/msm_iommu.c
... ... @@ -481,23 +481,19 @@
481 481  
482 482 priv = domain->priv;
483 483  
484   - if (!priv) {
485   - ret = -ENODEV;
  484 + if (!priv)
486 485 goto fail;
487   - }
488 486  
489 487 fl_table = priv->pgtable;
490 488  
491 489 if (len != SZ_16M && len != SZ_1M &&
492 490 len != SZ_64K && len != SZ_4K) {
493 491 pr_debug("Bad length: %d\n", len);
494   - ret = -EINVAL;
495 492 goto fail;
496 493 }
497 494  
498 495 if (!fl_table) {
499 496 pr_debug("Null page table\n");
500   - ret = -EINVAL;
501 497 goto fail;
502 498 }
503 499  
... ... @@ -506,7 +502,6 @@
506 502  
507 503 if (*fl_pte == 0) {
508 504 pr_debug("First level PTE is 0\n");
509   - ret = -ENODEV;
510 505 goto fail;
511 506 }
512 507