libbbfdm-ubus: free 'bbfdm_ctx' dynamic allocations only when 'ubus_ctx' is initialized

This commit is contained in:
Amin Ben Romdhane 2025-10-28 12:15:23 +00:00 committed by IOPSYS Dev
parent 1a86b8a443
commit 4855d91797
No known key found for this signature in database

View file

@ -1060,19 +1060,18 @@ int bbfdm_ubus_register_init(struct bbfdm_context *bbfdm_ctx)
int bbfdm_ubus_register_free(struct bbfdm_context *bbfdm_ctx)
{
free_apply_handlers(&bbfdm_ctx->config);
free_changed_uci(bbfdm_ctx);
if (bbfdm_ctx->ubus_ctx) {
ubus_unregister_event_handler(bbfdm_ctx->ubus_ctx, &bbfdm_ctx->apply_event);
free_ubus_event_handler(bbfdm_ctx->ubus_ctx, &bbfdm_ctx->event_handlers);
free_apply_handlers(&bbfdm_ctx->config);
free_changed_uci(bbfdm_ctx);
bbfdm_ctx_cleanup(bbfdm_ctx);
}
if (bbfdm_ctx->ubus_ctx && bbfdm_ctx->internal_ubus_ctx) {
ubus_free(bbfdm_ctx->ubus_ctx);
uloop_done();
}
bbfdm_ctx_cleanup(bbfdm_ctx);
return 0;
}