[PATCH 3/8] powerpc/nvram: Move an assignment for the variable "ret" in dev_nvram_write()

From: SF Markus Elfring
Date: Thu Jan 19 2017 - 12:03:59 EST


From: Markus Elfring <elfring@xxxxxxxxxxxxxxxxxxxxx>
Date: Thu, 19 Jan 2017 15:55:36 +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@xxxxxxxxxxxxxxxxxxxxx>
---
arch/powerpc/kernel/nvram_64.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/nvram_64.c b/arch/powerpc/kernel/nvram_64.c
index cf839adf3aa7..dc90a0e9ad65 100644
--- a/arch/powerpc/kernel/nvram_64.c
+++ b/arch/powerpc/kernel/nvram_64.c
@@ -806,9 +806,10 @@ static ssize_t dev_nvram_write(struct file *file, const char __user *buf,
if (!tmp)
return -ENOMEM;

- ret = -EFAULT;
- if (copy_from_user(tmp, buf, count))
+ if (copy_from_user(tmp, buf, count)) {
+ ret = -EFAULT;
goto out;
+ }

ret = ppc_md.nvram_write(tmp, count, ppos);

--
2.11.0