Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1561686

[PATCH 2/4] alpha: Move two assignments for the variable "error" in osf_utsname()

From SF Markus Elfring <elfring@users.sourceforge.net>
Newsgroups linux.kernel
Subject [PATCH 2/4] alpha: Move two assignments for the variable "error" in osf_utsname()
Date 2017-01-18 13:00 +0100
Message-ID <t0X4e-3E5-25@gated-at.bofh.it> (permalink)
References <t0WUy-3AT-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 18 Jan 2017 11:10:03 +0100

A local variable was set to an error code in one case before a concrete
error situation was detected. Thus move the corresponding assignment into
an if branch to indicate a software failure there.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/alpha/kernel/osf_sys.c | 22 ++++++++--------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/arch/alpha/kernel/osf_sys.c b/arch/alpha/kernel/osf_sys.c
index 41174156a676..73ff5d698591 100644
--- a/arch/alpha/kernel/osf_sys.c
+++ b/arch/alpha/kernel/osf_sys.c
@@ -528,20 +528,14 @@ SYSCALL_DEFINE1(osf_utsname, char __user *, name)
 	int error;
 
 	down_read(&uts_sem);
-	error = -EFAULT;
-	if (copy_to_user(name + 0, utsname()->sysname, 32))
-		goto out;
-	if (copy_to_user(name + 32, utsname()->nodename, 32))
-		goto out;
-	if (copy_to_user(name + 64, utsname()->release, 32))
-		goto out;
-	if (copy_to_user(name + 96, utsname()->version, 32))
-		goto out;
-	if (copy_to_user(name + 128, utsname()->machine, 32))
-		goto out;
-
-	error = 0;
- out:
+	if (copy_to_user(name + 0, utsname()->sysname, 32) ||
+	    copy_to_user(name + 32, utsname()->nodename, 32) ||
+	    copy_to_user(name + 64, utsname()->release, 32) ||
+	    copy_to_user(name + 96, utsname()->version, 32) ||
+	    copy_to_user(name + 128, utsname()->machine, 32))
+		error = -EFAULT;
+	else
+		error = 0;
 	up_read(&uts_sem);	
 	return error;
 }
-- 
2.11.0

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCH 0/4] alpha: Fine-tuning for five function implementations SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-18 12:50 +0100
  [PATCH 4/4] alpha: Move two assignments for the variable "res" in  srm_env_proc_write() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-18 13:00 +0100
    Re: [PATCH 4/4] alpha: Move two assignments for the variable "res"  in srm_env_proc_write() Jan-Benedict Glaw <jbglaw@lug-owl.de> - 2017-01-18 14:40 +0100
      Re: [PATCH 4/4] alpha: Move two assignments for the variable "res" in  srm_env_proc_write() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-18 15:30 +0100
    Re: [PATCH 4/4] alpha: Move two assignments for the variable "res"  in srm_env_proc_write() Al Viro <viro@ZenIV.linux.org.uk> - 2017-01-18 15:20 +0100
      Re: alpha: Checking source code positions for the setting of error  codes SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-18 17:00 +0100
        Re: alpha: Checking source code positions for the setting of error  codes Al Viro <viro@ZenIV.linux.org.uk> - 2017-01-18 18:50 +0100
    Re: [PATCH 4/4] alpha: Move two assignments for the variable "res"  in srm_env_proc_write() kbuild test robot <lkp@intel.com> - 2017-01-19 01:50 +0100
  [PATCH 3/4] alpha: Return directly after a failed copy_from_user() or  getname() in two functions SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-18 13:00 +0100
  [PATCH 2/4] alpha: Move two assignments for the variable "error" in  osf_utsname() SF Markus Elfring <elfring@users.sourceforge.net> - 2017-01-18 13:00 +0100

csiph-web