lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:   Wed, 24 Nov 2021 20:00:50 -0800
From:   Joe Perches <joe@...ches.com>
To:     Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>, rth@...ddle.net
Cc:     ink@...assic.park.msu.ru, mattst88@...il.com,
        linux-alpha@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] mm: Fix warning comparing pointer to 0

On Wed, 2021-11-24 at 18:13 +0800, Jiapeng Chong wrote:
> Fix the following coccicheck warning:
> 
> ./arch/alpha/mm/fault.c:193:52-53: WARNING comparing pointer to 0.
> 
> Reported-by: Abaci Robot <abaci@...ux.alibaba.com>
> Signed-off-by: Jiapeng Chong <jiapeng.chong@...ux.alibaba.com>
[]
> diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
[]
> @@ -190,7 +190,7 @@
>  
>   no_context:
>  	/* Are we prepared to handle this fault as an exception?  */
> -	if ((fixup = search_exception_tables(regs->pc)) != 0) {
> +	if (!(fixup = search_exception_tables(regs->pc)) {

This is now a reversed test.

The more typical kernel style is:

	fixup = search_exception_tables(regs->pc);
	if (fixup) {

>  		unsigned long newpc;
>  		newpc = fixup_exception(dpf_reg, fixup, regs->pc);
>  		regs->pc = newpc;

and it looks as if newpc is unnecessary.  Maybe:
---
 arch/alpha/mm/fault.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/alpha/mm/fault.c b/arch/alpha/mm/fault.c
index eee5102c3d889..364b6322629cb 100644
--- a/arch/alpha/mm/fault.c
+++ b/arch/alpha/mm/fault.c
@@ -192,10 +192,9 @@ do_page_fault(unsigned long address, unsigned long mmcsr,
 
  no_context:
 	/* Are we prepared to handle this fault as an exception?  */
-	if ((fixup = search_exception_tables(regs->pc)) != 0) {
-		unsigned long newpc;
-		newpc = fixup_exception(dpf_reg, fixup, regs->pc);
-		regs->pc = newpc;
+	fixup = search_exception_tables(regs->pc)
+	if (fixup) {
+		regs->pc = fixup_exception(dpf_reg, fixup, regs->pc);
 		return;
 	}
 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ