From b5cce0cb8166cc9cf1b677b55ead31746496ba51 Mon Sep 17 00:00:00 2001 From: Kay Sievers Date: Sat, 18 Jan 2014 16:35:48 +0100 Subject: [PATCH] do not shortcut handle state with KDBUS_CMD_BYEBYE, it leaks the namespace ref --- handle.c | 4 ---- test/test-kdbus.c | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/handle.c b/handle.c index 351136b..4517cf5 100644 --- a/handle.c +++ b/handle.c @@ -507,10 +507,6 @@ static long kdbus_handle_ioctl_ep_connected(struct file *file, unsigned int cmd, switch (cmd) { case KDBUS_CMD_BYEBYE: ret = kdbus_conn_disconnect(conn, true); - if (ret == 0) { - kdbus_conn_unref(conn); - handle->type = KDBUS_HANDLE_DISCONNECTED; - } break; case KDBUS_CMD_EP_POLICY_SET: diff --git a/test/test-kdbus.c b/test/test-kdbus.c index 0104701..e7aaa10 100644 --- a/test/test-kdbus.c +++ b/test/test-kdbus.c @@ -474,9 +474,9 @@ static int check_byebye(struct kdbus_check_env *env) ret = ioctl(conn->fd, KDBUS_CMD_BYEBYE, 0); ASSERT_RETURN(ret == 0); - /* a 2nd try should result in -EBADFD */ + /* a 2nd try should result in -EALREADY */ ret = ioctl(conn->fd, KDBUS_CMD_BYEBYE, 0); - ASSERT_RETURN(ret == -1 && errno == EBADFD); + ASSERT_RETURN(ret == -1 && errno == EALREADY); free_conn(conn); -- 2.34.1