[PATCH 5/5] s390/pci: Move two assignments for the variable "ret" in get_pfn()

From: SF Markus Elfring
Date: Sat Jan 21 2017 - 13:15:14 EST


From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Sat, 21 Jan 2017 18:48:45 +0100

A local variable was set to an error code in two cases before a concrete
error situation was detected. Thus move the corresponding assignments into
if branches to indicate a software failure there.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
---
arch/s390/pci/pci_mmio.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/arch/s390/pci/pci_mmio.c b/arch/s390/pci/pci_mmio.c
index f125858a77e9..400af13ef275 100644
--- a/arch/s390/pci/pci_mmio.c
+++ b/arch/s390/pci/pci_mmio.c
@@ -18,13 +18,15 @@ static long get_pfn(unsigned long user_addr, unsigned long access,
long ret;

down_read(&current->mm->mmap_sem);
- ret = -EINVAL;
vma = find_vma(current->mm, user_addr);
- if (!vma)
+ if (!vma) {
+ ret = -EINVAL;
goto out;
- ret = -EACCES;
- if (!(vma->vm_flags & access))
+ }
+ if (!(vma->vm_flags & access)) {
+ ret = -EACCES;
goto out;
+ }
ret = follow_pfn(vma, user_addr, pfn);
out:
up_read(&current->mm->mmap_sem);
--
2.11.0