Skip to content

Commit bbd95c0

Browse files
committed
ucode: add ubus refcounting fix
Fixes a regression in the last ucode update Signed-off-by: Felix Fietkau <nbd@nbd.name>
1 parent 9850052 commit bbd95c0

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
From: Felix Fietkau <nbd@nbd.name>
2+
Date: Wed, 18 Jun 2025 17:26:49 +0200
3+
Subject: [PATCH] ubus: fix refcount issue in uc_ubus_object_notify
4+
5+
uc_ubus_object_notify_complete_cb will clear the reference in notify_ctx->res,
6+
so in the synchronous case, an extra ucv_get call is needed.
7+
Fixes an accidental double-unref bug
8+
9+
Fixes: 94ad17d13a0d ("ubus: use ucv_resource_create_ex for ubus.notify resources")
10+
Signed-off-by: Felix Fietkau <nbd@nbd.name>
11+
---
12+
13+
--- a/lib/ubus.c
14+
+++ b/lib/ubus.c
15+
@@ -1290,7 +1290,6 @@ uc_ubus_object_notify(uc_vm_t *vm, size_
16+
17+
notifyctx->vm = vm;
18+
notifyctx->ctx = uuobj->ctx;
19+
- notifyctx->res = res;
20+
21+
blob_buf_init(&buf, 0);
22+
23+
@@ -1306,6 +1305,7 @@ uc_ubus_object_notify(uc_vm_t *vm, size_
24+
err_return(rv, "Failed to send notification");
25+
}
26+
27+
+ notifyctx->res = ucv_get(res);
28+
notifyctx->req.data_cb = uc_ubus_object_notify_data_cb;
29+
notifyctx->req.status_cb = uc_ubus_object_notify_status_cb;
30+
notifyctx->req.complete_cb = uc_ubus_object_notify_complete_cb;
31+
@@ -1326,7 +1326,7 @@ uc_ubus_object_notify(uc_vm_t *vm, size_
32+
ucv_resource_persistent_set(res, true);
33+
ubus_complete_request_async(uuobj->ctx, &notifyctx->req.req);
34+
35+
- ok_return(ucv_get(res));
36+
+ ok_return(res);
37+
}
38+
39+

0 commit comments

Comments
 (0)