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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux