From: Yu Watanabe Date: Mon, 31 Mar 2025 17:07:54 +0000 (+0900) Subject: sysupdate-transfer: fix potential memleak X-Git-Tag: v258-rc1~975^2~2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=66936ba5fa61be864d2de6b82f8897b39b2fff51;p=thirdparty%2Fsystemd.git sysupdate-transfer: fix potential memleak --- diff --git a/src/sysupdate/sysupdate-transfer.c b/src/sysupdate/sysupdate-transfer.c index 26d65d4078e..da10aa81bcd 100644 --- a/src/sysupdate/sysupdate-transfer.c +++ b/src/sysupdate/sysupdate-transfer.c @@ -945,15 +945,13 @@ static int callout_context_new(const Transfer *t, const Instance *i, TransferPro } static int helper_on_exit(sd_event_source *s, const siginfo_t *si, void *userdata) { - _cleanup_(callout_context_freep) CalloutContext *ctx = ASSERT_PTR(userdata); + CalloutContext *ctx = ASSERT_PTR(userdata); int r; assert(s); assert(si); assert(ctx); - pidref_done(&ctx->pid); - if (si->si_code == CLD_EXITED) { if (si->si_status == EXIT_SUCCESS) { r = 0; @@ -1043,7 +1041,6 @@ static int run_callout( assert(cmdline[0]); _cleanup_(callout_context_freep) CalloutContext *ctx = NULL; - r = callout_context_new(transfer, instance, callback, name, userdata, &ctx); if (r < 0) return log_oom(); @@ -1097,7 +1094,7 @@ static int run_callout( } /* Quit the loop w/ when child process exits */ - r = event_add_child_pidref(event, &exit_source, &ctx->pid, WEXITED, helper_on_exit, (void*) ctx); + r = event_add_child_pidref(event, &exit_source, &ctx->pid, WEXITED, helper_on_exit, ctx); if (r < 0) return log_error_errno(r, "Failed to add child process to event loop: %m"); @@ -1106,7 +1103,7 @@ static int run_callout( return log_error_errno(r, "Failed to take ownership of child process: %m"); /* Propagate sd_notify calls */ - r = sd_event_add_io(event, ¬ify_source, fd, EPOLLIN, helper_on_notify, TAKE_PTR(ctx)); + r = sd_event_add_io(event, ¬ify_source, fd, EPOLLIN, helper_on_notify, ctx); if (r < 0) return log_error_errno(r, "Failed to add notification propagation to event loop: %m");