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


Groups > linux.kernel > #1226797

[PATCH] arch-powerpc: Return false instead of -EFAULT

From Peter Senna Tschudin <peter.senna@gmail.com>
Newsgroups linux.kernel
Subject [PATCH] arch-powerpc: Return false instead of -EFAULT
Date 2015-09-17 11:20 +0200
Message-ID <q9Dwf-7Az-31@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


Returning a negative value for a boolean function seem to have the
undesired effect of returning true. Replace -EINVAL by false in a
bool-returning function.

The diff of the .s file before and after the change (using cross
compilation) starts with:

440,441c440,441
< .L43:
< 	li 3,1	 # D.25775,
---
> .L42:
> 	li 3,0	 # D.25775,
...

while if -EFAULT is replaced by true, the diff is empty.

There is only one call site, and it expects a boolean value:
arch/powerpc/kernel/ftrace.c:129:
        if (!is_module_trampoline(tramp)) {
                pr_err("Not a trampoline\n");
                return -EINVAL;
        }

This issue was found by the following Coccinelle semantic patch:
<smpl>
@@
identifier f;
constant C;
typedef bool;
@@
bool f (...){
<+...
* return -C;
...+>
}
</smpl>

Signed-off-by: Peter Senna Tschudin <peter.senna@gmail.com>
---
 arch/powerpc/kernel/module_64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c
index 6838451..a94a5f1 100644
--- a/arch/powerpc/kernel/module_64.c
+++ b/arch/powerpc/kernel/module_64.c
@@ -160,7 +160,7 @@ bool is_module_trampoline(u32 *p)
 	BUILD_BUG_ON(sizeof(ppc64_stub_insns) != sizeof(ppc64_stub_mask));
 
 	if (probe_kernel_read(insns, p, sizeof(insns)))
-		return -EFAULT;
+		return false;
 
 	for (i = 0; i < ARRAY_SIZE(ppc64_stub_insns); i++) {
 		u32 insna = insns[i];
-- 
2.1.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

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


Thread

[PATCH] arch-powerpc: Return false instead of -EFAULT Peter Senna Tschudin <peter.senna@gmail.com> - 2015-09-17 11:20 +0200
  Re: [PATCH] arch-powerpc: Return false instead of -EFAULT Michael Ellerman <mpe@ellerman.id.au> - 2015-09-17 11:50 +0200
    Re: [PATCH] arch-powerpc: Return false instead of -EFAULT Peter Senna Tschudin <peter.senna@gmail.com> - 2015-09-17 12:00 +0200

csiph-web