All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH] syscalls/shmctl05: Remove shm segment only when created
@ 2021-09-15 15:25 ` Cyril Hrubis
  2021-09-16  1:55     ` xuyang2018.jy
  0 siblings, 1 reply; 2+ messages in thread
From: Cyril Hrubis @ 2021-09-15 15:25 UTC (permalink / raw)
  To: ltp

We cannot remove the shm segment unconditionally. On kernels without
SysV IPC support compiled in the test fails with following:

shmctl05.c:50: TCONF: syscall(396) __NR_shmctl not supported
shmctl05.c:96: TWARN: shmget(61455, 4096, 0) failed: ENOENT (2)
shmctl05.c:97: TWARN: shmctl(-1, 0, (nil)) failed: EINVAL (22)

Fixes: 48d382e8daf2 (syscalls/shmctl05.c: Fix leak of shared memory segment)
Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
CC: Yang Xu <xuyang2018.jy@fujitsu.com>
---
 testcases/kernel/syscalls/ipc/shmctl/shmctl05.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/ipc/shmctl/shmctl05.c b/testcases/kernel/syscalls/ipc/shmctl/shmctl05.c
index ea7eef6f1..8569322dc 100644
--- a/testcases/kernel/syscalls/ipc/shmctl/shmctl05.c
+++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl05.c
@@ -92,8 +92,16 @@ static void do_test(void)
 static void cleanup(void)
 {
 	int id;
+
 	tst_fzsync_pair_cleanup(&fzsync_pair);
-	id = SAFE_SHMGET(0xF00F, 4096, 0);
+
+	id = shmget(0xF00F, 4096, 0);
+	if (id == -1) {
+		if (errno != ENOENT)
+			tst_res(TWARN | TERRNO, "shmget()");
+		return;
+	}
+
 	SAFE_SHMCTL(id, IPC_RMID, NULL);
 }
 
-- 
2.32.0


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [LTP] [PATCH] syscalls/shmctl05: Remove shm segment only when created
@ 2021-09-16  1:55     ` xuyang2018.jy
  0 siblings, 0 replies; 2+ messages in thread
From: xuyang2018.jy @ 2021-09-16  1:55 UTC (permalink / raw)
  To: Cyril Hrubis; +Cc: ltp

Hi Cyril
Thanks for this fix, merged.

Best Regards
Yang Xu
> We cannot remove the shm segment unconditionally. On kernels without
> SysV IPC support compiled in the test fails with following:
> 
> shmctl05.c:50: TCONF: syscall(396) __NR_shmctl not supported
> shmctl05.c:96: TWARN: shmget(61455, 4096, 0) failed: ENOENT (2)
> shmctl05.c:97: TWARN: shmctl(-1, 0, (nil)) failed: EINVAL (22)
> 
> Fixes: 48d382e8daf2 (syscalls/shmctl05.c: Fix leak of shared memory segment)
> Signed-off-by: Cyril Hrubis<chrubis@suse.cz>
> CC: Yang Xu<xuyang2018.jy@fujitsu.com>
> ---
>   testcases/kernel/syscalls/ipc/shmctl/shmctl05.c | 10 +++++++++-
>   1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/testcases/kernel/syscalls/ipc/shmctl/shmctl05.c b/testcases/kernel/syscalls/ipc/shmctl/shmctl05.c
> index ea7eef6f1..8569322dc 100644
> --- a/testcases/kernel/syscalls/ipc/shmctl/shmctl05.c
> +++ b/testcases/kernel/syscalls/ipc/shmctl/shmctl05.c
> @@ -92,8 +92,16 @@ static void do_test(void)
>   static void cleanup(void)
>   {
>   	int id;
> +
>   	tst_fzsync_pair_cleanup(&fzsync_pair);
> -	id = SAFE_SHMGET(0xF00F, 4096, 0);
> +
> +	id = shmget(0xF00F, 4096, 0);
> +	if (id == -1) {
> +		if (errno != ENOENT)
> +			tst_res(TWARN | TERRNO, "shmget()");
> +		return;
> +	}
> +
>   	SAFE_SHMCTL(id, IPC_RMID, NULL);
>   }
> 

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-09-16  1:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-15 15:25 [LTP] [PATCH] syscalls/shmctl05: Remove shm segment only when created Cyril Hrubis
2021-09-15 15:25 ` Cyril Hrubis
2021-09-16  1:55   ` xuyang2018.jy
2021-09-16  1:55     ` xuyang2018.jy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.