mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Danish Khateeb <danishkhateeb03@gmail.com>
To: Paul Walmsley <pjw@kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	Alexandre Ghiti <alex@ghiti.fr>
Cc: "Shuah Khan" <shuah@kernel.org>, "Andy Chiu" <andybnac@gmail.com>,
	"Sergey Matyukevich" <geomatsi@gmail.com>,
	"Thomas Weißschuh" <linux@weissschuh.net>,
	linux-riscv@lists.infradead.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	"Danish Khateeb" <danishkhateeb03@gmail.com>,
	"kernel test robot" <lkp@intel.com>
Subject: [PATCH 1/2] selftests: riscv: vstate_exec_nolibc: Check the return value of waitpid()
Date: Sat, 26 Sep 2026 10:55:34 -0500	[thread overview]
Message-ID: <20260926155535.306111-2-danishkhateeb03@gmail.com> (raw)
In-Reply-To: <20260926155535.306111-1-danishkhateeb03@gmail.com>

vstate_exec_nolibc does not check whether waitpid() succeeds, so status
is used uninitialized if it fails. Since nolibc implements waitpid() on
top of waitid(), GCC can see this, and warns:

  vstate_exec_nolibc.c:78:12: warning: 'status' may be used uninitialized [-Wmaybe-uninitialized]

Fail if waitpid() fails, as launch_test() does for the same call.

Fixes: 7cf6198ce22d ("selftests: Test RISC-V Vector prctl interface")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/r/202609250003.hvssJlRZ-lkp@intel.com/
Assisted-by: LLM
Signed-off-by: Danish Khateeb <danishkhateeb03@gmail.com>
---
 tools/testing/selftests/riscv/vector/vstate_exec_nolibc.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/testing/selftests/riscv/vector/vstate_exec_nolibc.c b/tools/testing/selftests/riscv/vector/vstate_exec_nolibc.c
index 12f1b1b1c7aa..5f53e5e8ac52 100644
--- a/tools/testing/selftests/riscv/vector/vstate_exec_nolibc.c
+++ b/tools/testing/selftests/riscv/vector/vstate_exec_nolibc.c
@@ -69,6 +69,10 @@ int main(int argc, char **argv)
 	}
 
 	rc = waitpid(-1, &status, 0);
+	if (rc == -1) {
+		puts("waitpid failed\n");
+		exit(-1);
+	}
 
 	if (WIFEXITED(status) && WEXITSTATUS(status) == -1) {
 		puts("child exited abnormally\n");
-- 
2.55.0


  reply	other threads:[~2026-09-26 15:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-26 15:55 [PATCH 0/2] selftests: riscv: vector: Fix the checks of the child's exit status Danish Khateeb
2026-09-26 15:55 ` Danish Khateeb [this message]
2026-09-26 15:55 ` [PATCH 2/2] selftests: riscv: vector: Fix the check for children exiting with -1 Danish Khateeb

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260926155535.306111-2-danishkhateeb03@gmail.com \
    --to=danishkhateeb03@gmail.com \
    --cc=alex@ghiti.fr \
    --cc=andybnac@gmail.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=geomatsi@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=linux@weissschuh.net \
    --cc=lkp@intel.com \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®