All of lore.kernel.org
 help / color / mirror / Atom feed
From: Cyril Hrubis <chrubis@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] syscalls/shmctl05: Remove shm segment only when created
Date: Wed, 15 Sep 2021 17:25:33 +0200	[thread overview]
Message-ID: <20210915152533.20902-1-chrubis@suse.cz> (raw)
Message-ID: <20210915152533.nMZpqn1NaFu5_IrUMgZk0ItmMAvwHbWM7Mm7IwGke7U@z> (raw)

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

             reply	other threads:[~2021-09-15 15:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-15 15:25 Cyril Hrubis [this message]
2021-09-15 15:25 ` [LTP] [PATCH] syscalls/shmctl05: Remove shm segment only when created Cyril Hrubis
2021-09-16  1:55   ` xuyang2018.jy
2021-09-16  1:55     ` xuyang2018.jy

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=20210915152533.20902-1-chrubis@suse.cz \
    --to=chrubis@suse.cz \
    --cc=ltp@lists.linux.it \
    /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 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.