diff mbox series

syscalls/statvfs01: Close fd only on success

Message ID 20230118155009.16593-1-chrubis@suse.cz
State Accepted
Headers show
Series syscalls/statvfs01: Close fd only on success | expand

Commit Message

Cyril Hrubis Jan. 18, 2023, 3:50 p.m. UTC
This fixes TBROK in the case that the creat() call has failed
unexpectedly and allows the test to continue.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 testcases/kernel/syscalls/statvfs/statvfs01.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Petr Vorel Jan. 18, 2023, 4:42 p.m. UTC | #1
Hi Cyril,

Obviously correct as well, thanks for fixing it.
Reviewed-by: Petr Vorel <pvorel@suse.cz>

Kind regards,
Petr
diff mbox series

Patch

diff --git a/testcases/kernel/syscalls/statvfs/statvfs01.c b/testcases/kernel/syscalls/statvfs/statvfs01.c
index f17dc4cfa..c10c67b18 100644
--- a/testcases/kernel/syscalls/statvfs/statvfs01.c
+++ b/testcases/kernel/syscalls/statvfs/statvfs01.c
@@ -42,7 +42,8 @@  static void run(void)
 	toolong_fname[valid_len+1] = 0;
 
 	TST_EXP_FD(creat(valid_fname, 0444));
-	SAFE_CLOSE(TST_RET);
+	if (TST_PASS)
+		SAFE_CLOSE(TST_RET);
 
 	TST_EXP_FAIL(creat(toolong_fname, 0444), ENAMETOOLONG);
 }