From: Markus Elfring <elfr...@users.sourceforge.net>
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 <elfr...@users.sourceforge.net>
---
 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

Reply via email to