diff options
author | Felix Fietkau <nbd@nbd.name> | 2021-08-09 12:49:34 +0200 |
---|---|---|
committer | Felix Fietkau <nbd@nbd.name> | 2021-09-08 12:25:31 +0200 |
commit | 2099bb3ad9972c6188c38fd885ae74f3323fcacc (patch) | |
tree | 4bca2c2fa40f8e77e7f1ecbac93214ca272e1c9f | |
parent | b743a331421dc13dc99dabb3f102c58889a194d2 (diff) | |
download | ubus-2099bb3ad9972c6188c38fd885ae74f3323fcacc.tar.gz |
libubus: use list_empty/list_first_entry in ubus_process_pending_msg
Simplifies checks and avoids potential list corruption on recursive calls
Signed-off-by: Felix Fietkau <nbd@nbd.name>
-rw-r--r-- | libubus.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -115,12 +115,13 @@ ubus_process_msg(struct ubus_context *ctx, struct ubus_msghdr_buf *buf, int fd) static void ubus_process_pending_msg(struct uloop_timeout *timeout) { struct ubus_context *ctx = container_of(timeout, struct ubus_context, pending_timer); - struct ubus_pending_msg *pending, *tmp; + struct ubus_pending_msg *pending; - list_for_each_entry_safe(pending, tmp, &ctx->pending, list) { + while (!list_empty(&ctx->pending)) { if (ctx->stack_depth) break; + pending = list_first_entry(&ctx->pending, struct ubus_pending_msg, list); list_del(&pending->list); ubus_process_msg(ctx, &pending->hdr, -1); free(pending); |