chiark / gitweb /
sd-bus: don't leak kdbus notifications
authorDavid Herrmann <dh.herrmann@gmail.com>
Thu, 2 Jul 2015 10:14:27 +0000 (12:14 +0200)
committerSven Eden <yamakuzure@gmx.net>
Tue, 14 Mar 2017 09:05:54 +0000 (10:05 +0100)
When we get notifications from the kernel, we always turn them into
synthetic dbus1 messages. This means, we do *not* consume the kdbus
message, and as such have to free the offset.

Right now, the translation-helpers told the caller that they consumed the
message, which is wrong. Fix this by explicitly releasing all kernel
messages that are translated.

src/libelogind/sd-bus/bus-kernel.c

index f08db2da893c25d13f4986b4b50cbe9f38ade677..e3fac01f9284a5885b5a90a7cd39cd392496da85 100644 (file)
@@ -1385,15 +1385,16 @@ int bus_kernel_read_message(sd_bus *bus, bool hint_priority, int64_t priority) {
                         r = 0;
                 }
 
-        } else if (k->payload_type == KDBUS_PAYLOAD_KERNEL)
+                if (r <= 0)
+                        close_kdbus_msg(bus, k);
+        } else if (k->payload_type == KDBUS_PAYLOAD_KERNEL) {
                 r = bus_kernel_translate_message(bus, k);
-        else {
+                close_kdbus_msg(bus, k);
+        } else {
                 log_debug("Ignoring message with unknown payload type %llu.", (unsigned long long) k->payload_type);
                 r = 0;
-        }
-
-        if (r <= 0)
                 close_kdbus_msg(bus, k);
+        }
 
         return r < 0 ? r : 1;
 }