linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] powerpc/rtas_flash: Move an assignment for the variable "rc" in manage_flash_write()
@ 2017-01-19 20:33 SF Markus Elfring
  2017-01-20  0:10 ` Tyrel Datwyler
  0 siblings, 1 reply; 2+ messages in thread
From: SF Markus Elfring @ 2017-01-19 20:33 UTC (permalink / raw)
  To: linuxppc-dev, Benjamin Herrenschmidt, Michael Ellerman,
	Paul Mackerras
  Cc: LKML, kernel-janitors

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 19 Jan 2017 21:20:09 +0100

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

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 arch/powerpc/kernel/rtas_flash.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/rtas_flash.c b/arch/powerpc/kernel/rtas_flash.c
index db2b482af658..663904beff67 100644
--- a/arch/powerpc/kernel/rtas_flash.c
+++ b/arch/powerpc/kernel/rtas_flash.c
@@ -419,9 +419,10 @@ static ssize_t manage_flash_write(struct file *file, const char __user *buf,
 	op = -1;
 	if (buf) {
 		if (count > 9) count = 9;
-		rc = -EFAULT;
-		if (copy_from_user (stkbuf, buf, count))
+		if (copy_from_user(stkbuf, buf, count)) {
+			rc = -EFAULT;
 			goto error;
+		}
 		if (strncmp(stkbuf, reject_str, strlen(reject_str)) == 0) 
 			op = RTAS_REJECT_TMP_IMG;
 		else if (strncmp(stkbuf, commit_str, strlen(commit_str)) == 0) 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-01-20  0:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-01-19 20:33 [PATCH] powerpc/rtas_flash: Move an assignment for the variable "rc" in manage_flash_write() SF Markus Elfring
2017-01-20  0:10 ` Tyrel Datwyler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).