summaryrefslogtreecommitdiff
path: root/ipc
diff options
context:
space:
mode:
authorPaul Osmialowski <p.osmialowsk@samsung.com>2015-06-18 17:29:11 +0200
committerSeung-Woo Kim <sw0312.kim@samsung.com>2016-12-14 13:48:46 +0900
commit3edf5241b2d79dfcd8faf5173ff5fda04de0b070 (patch)
tree5cbdd4a0e6bbc9cc065e6fe231ef0bed07c93988 /ipc
parentb41252abc255f7e0eb605833f7bdf3496995fa84 (diff)
kdbus: do not append the same connection to the queue twice
As it was discussed on systemd ML [1], the same connection should be queued up only once for a given well-known name. [1] http://lists.freedesktop.org/archives/systemd-devel/2015-April/030494.html This commit fixes following issue: [ 243.364270] ------------[ cut here ]------------ [ 243.364352] WARNING: CPU: 1 PID: 223 at ../ipc/kdbus/names.c:137 kdbus_name_entry_replace_owner+0x88/0x8c() [ 243.364408] Modules linked in: [ 243.364474] CPU: 1 PID: 223 Comm: kdbus-test Not tainted 4.0.0+ #1 [ 243.364526] Hardware name: Foundation-v8A (DT) [ 243.364569] Call trace: [ 243.364639] [<ffff800000089d38>] dump_backtrace+0x0/0x12c [ 243.364718] [<ffff800000089e74>] show_stack+0x10/0x1c [ 243.364798] [<ffff8000006642f4>] dump_stack+0x74/0x98 [ 243.364874] [<ffff8000000b282c>] warn_slowpath_common+0x98/0xd0 [ 243.364951] [<ffff8000000b2928>] warn_slowpath_null+0x14/0x20 [ 243.365026] [<ffff8000003cf7a4>] kdbus_name_entry_replace_owner+0x84/0x8c [ 243.365105] [<ffff8000003cf7e0>] kdbus_name_release_unlocked.isra.5+0x34/0x170 [ 243.365183] [<ffff8000003d0554>] kdbus_cmd_name_release+0x1b8/0x1c8 [ 243.365270] [<ffff8000003cbd28>] kdbus_handle_ioctl+0x5e0/0x690 [ 243.365347] [<ffff8000001b3520>] do_vfs_ioctl+0x31c/0x5c0 [ 243.365423] [<ffff8000001b3844>] SyS_ioctl+0x80/0x98 [ 243.365473] ---[ end trace 5bf3630c98408d38 ]--- Signed-off-by: Lukasz Skalski <l.skalski@samsung.com> Signed-off-by: Paul Osmialowski <p.osmialowsk@samsung.com>
Diffstat (limited to 'ipc')
-rw-r--r--ipc/kdbus/names.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/ipc/kdbus/names.c b/ipc/kdbus/names.c
index 657008e1bb37..df99e4df815b 100644
--- a/ipc/kdbus/names.c
+++ b/ipc/kdbus/names.c
@@ -353,10 +353,24 @@ int kdbus_name_acquire(struct kdbus_name_registry *reg,
} else if (flags & KDBUS_NAME_QUEUE) {
/* add to waiting-queue of the name */
- ret = kdbus_name_pending_new(e, conn, flags);
- if (ret >= 0)
- /* tell the caller that we queued it */
- rflags |= KDBUS_NAME_IN_QUEUE;
+ struct kdbus_name_pending *p;
+ bool in_queue = false;
+
+ list_for_each_entry(p, &e->queue, name_entry) {
+ if (p->conn == conn) {
+ /* connection is already queued */
+ rflags |= KDBUS_NAME_IN_QUEUE;
+ in_queue = true;
+ break;
+ }
+ }
+
+ if (!in_queue) {
+ ret = kdbus_name_pending_new(e, conn, flags);
+ if (ret >= 0)
+ /* tell the caller that we queued it */
+ rflags |= KDBUS_NAME_IN_QUEUE;
+ }
} else {
/* the name is busy, return a failure */
ret = -EEXIST;