From: xuyang2018.jy@fujitsu.com Date: Thu, 16 Sep 2021 01:55:01 +0000 Subject: [LTP] [PATCH] syscalls/shmctl05: Remove shm segment only when created In-Reply-To: <20210915152533.20902-1-chrubis@suse.cz> References: <20210915152533.20902-1-chrubis@suse.cz> Message-ID: <6142A409.1090605@fujitsu.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: ltp@lists.linux.it 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 > CC: Yang Xu > --- > 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); > } >