sd-bus: don't leak kdbus notifications

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.
This commit is contained in:
David Herrmann 2015-07-02 12:14:27 +02:00
parent 138879ccad
commit 0c9cc10dcc

View 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;
}