sd-netlink: pin reply slot while we execute callback

The callback might drop the last ref to the slot object, and we still
want to access it. Hence do what we usually do in these cases: keep an
extra reference while processing the callback.
This commit is contained in:
Lennart Poettering
2026-02-24 17:09:33 +01:00
parent c8aa7b152f
commit 332ecf40f2
+2 -2
View File
@@ -331,7 +331,6 @@ static int process_timeout(sd_netlink *nl) {
static int process_reply(sd_netlink *nl, sd_netlink_message *m) {
struct reply_callback *c;
sd_netlink_slot *slot;
uint32_t serial;
uint16_t type;
int r;
@@ -354,7 +353,8 @@ static int process_reply(sd_netlink *nl, sd_netlink_message *m) {
if (type == NLMSG_DONE)
m = NULL;
slot = container_of(c, sd_netlink_slot, reply_callback);
_cleanup_(sd_netlink_slot_unrefp) sd_netlink_slot *slot =
sd_netlink_slot_ref(container_of(c, sd_netlink_slot, reply_callback));
r = c->callback(nl, m, slot->userdata);
if (r < 0)