Skip to contentSkip to conversation

syscalls/name_to_handle_at: Clean memory after calling name_to_handle_at

PATCH New Zhao Gongyi 2 participants 2 messages Apr 23, 2021 – Apr 26, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 syscalls/name_to_handle_at: Clean memory after calling name_to_handle_at

Need to cleanup memory after calling name_to_handle_at, otherwise the test will fail when we run with option '-i', as follows:

./name_to_handle_at02 -i 2
tst_test.c:1313: TINFO: Timeout per run is 0h 05m 00s name_to_handle_at02.c:74: TPASS: invalid-dfd: name_to_handle_at() failed as expected: EBADF (9)
name_to_handle_at02.c:74: TPASS: not a directory: name_to_handle_at() failed as expected: ENOTDIR (20)
name_to_handle_at02.c:74: TPASS: invalid-path: name_to_handle_at() failed as expected: EFAULT (14)
name_to_handle_at02.c:74: TPASS: invalid-file-handle:
name_to_handle_at() failed as expected: EFAULT (14) name_to_handle_at02.c:74: TPASS: zero-file-handle-size:
name_to_handle_at() failed as expected: EOVERFLOW (75) name_to_handle_at02.c:74: TPASS: high-file-handle-size:
name_to_handle_at() failed as expected: EINVAL (22) name_to_handle_at02.c:74: TPASS: invalid-mount_id: name_to_handle_at() failed as expected: EFAULT (14)
name_to_handle_at02.c:74: TPASS: invalid-flags: name_to_handle_at() failed as expected: EINVAL (22)
name_to_handle_at02.c:74: TPASS: empty-path: name_to_handle_at() failed as expected: ENOENT (2)
name_to_handle_at02.c:74: TPASS: invalid-dfd: name_to_handle_at() failed as expected: EBADF (9)
name_to_handle_at02.c:74: TPASS: not a directory: name_to_handle_at() failed as expected: ENOTDIR (20)
name_to_handle_at02.c:74: TPASS: invalid-path: name_to_handle_at() failed as expected: EFAULT (14)
name_to_handle_at02.c:74: TPASS: invalid-file-handle:
name_to_handle_at() failed as expected: EFAULT (14) name_to_handle_at02.c:62: TFAIL: zero-file-handle-size:
name_to_handle_at() passed unexpectedly name_to_handle_at02.c:74: TPASS: high-file-handle-size:
name_to_handle_at() failed as expected: EINVAL (22) name_to_handle_at02.c:74: TPASS: invalid-mount_id: name_to_handle_at() failed as expected: EFAULT (14)
name_to_handle_at02.c:74: TPASS: invalid-flags: name_to_handle_at() failed as expected: EINVAL (22)
name_to_handle_at02.c:74: TPASS: empty-path: name_to_handle_at() failed as expected: ENOENT (2)

Summary:

passed   17
failed   1
broken   0
skipped  0

warnings 0

---
 .../kernel/syscalls/name_to_handle_at/name_to_handle_at02.c    | 3 +++
 1 file changed, 3 insertions(+)
testcases/kernel/syscalls/name_to_handle_at/name_to_handle_at02.c +3 -0
index d60c8a0c1..e3e77ef3f 100644
@@ -54,6 +54,9 @@ static void run(unsigned int n)
 {
 	struct tcase *tc = &tcases[n];
 
+	/* Need to clean memory after calling name_to_handle_at. */
+	memset(&fh, 0, sizeof(fh));
+
 	TEST(name_to_handle_at(tc->dfd, *tc->pathname, *tc->fhp, *tc->mount_id,
 			       tc->flags));
 

--
2.17.1

#1 lore raw

PATCH 1/1 syscalls/name_to_handle_at: Clean memory after calling name_to_handle_at

Hi,

good catch, merged (with slightly modified commit message, removed comment as git commit message is enough).

Kind regards,
Petr