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]
Message-ID: <87h6a1aymy.fsf@gmail.com>
Date: Fri, 27 Sep 2024 21:15:41 +0530
From: Ritesh Harjani (IBM) <ritesh.list@...il.com>
To: zhangjiao2 <zhangjiao2@...s.chinamobile.com>, shuah@...nel.org
Cc: mpe@...erman.id.au, linuxppc-dev@...ts.ozlabs.org, linux-kselftest@...r.kernel.org, linux-kernel@...r.kernel.org, zhang jiao <zhangjiao2@...s.chinamobile.com>
Subject: Re: [PATCH] selftests/powerpc: Rm the unnecessary remove function.

zhangjiao2 <zhangjiao2@...s.chinamobile.com> writes:

> From: zhang jiao <zhangjiao2@...s.chinamobile.com>
>
> Path is not initialized before use,
> remove the unnecessary remove function.
>
> Signed-off-by: zhang jiao <zhangjiao2@...s.chinamobile.com>
> ---
>  tools/testing/selftests/powerpc/mm/tlbie_test.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/tools/testing/selftests/powerpc/mm/tlbie_test.c b/tools/testing/selftests/powerpc/mm/tlbie_test.c
> index 48344a74b212..fd1456d16a7d 100644
> --- a/tools/testing/selftests/powerpc/mm/tlbie_test.c
> +++ b/tools/testing/selftests/powerpc/mm/tlbie_test.c
> @@ -314,7 +314,6 @@ static inline void end_verification_log(unsigned int tid, unsigned nr_anamolies)
>  	fclose(f);
>  
>  	if (nr_anamolies == 0) {
> -		remove(path);
>  		return;
>  	}

Nice catch. Indeed the path is uninitialized here. 

However, I believe the above "if" block should come after initializing
the path. The idea is if there were no anamolies noted, then we can
simply remove the log file and return.

Something like below. Thoughts?

diff --git a/tools/testing/selftests/powerpc/mm/tlbie_test.c b/tools/testing/selftests/powerpc/mm/tlbie_test.c
index 48344a74b212..35f0098399cc 100644
--- a/tools/testing/selftests/powerpc/mm/tlbie_test.c
+++ b/tools/testing/selftests/powerpc/mm/tlbie_test.c
@@ -313,16 +313,16 @@ static inline void end_verification_log(unsigned int tid, unsigned nr_anamolies)

        fclose(f);

-       if (nr_anamolies == 0) {
-               remove(path);
-               return;
-       }
-
        sprintf(logfile, logfilename, tid);
        strcpy(path, logdir);
        strcat(path, separator);
        strcat(path, logfile);

+       if (nr_anamolies == 0) {
+               remove(path);
+               return;
+       }
+
        printf("Thread %02d chunk has %d corrupted words. For details check %s\n",
                tid, nr_anamolies, path);
 }


-ritesh

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ