From 25cbe2a2b8f35ca3f70a42cf0680a112ed644703 Mon Sep 17 00:00:00 2001 From: Shelby Hagman Date: Mon, 9 Feb 2026 21:17:51 +0000 Subject: [PATCH] filter_kubernetes: Adjust cleanup ordering to avoid use-after-free Signed-off-by: Shelby Hagman --- plugins/filter_kubernetes/kube_conf.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/plugins/filter_kubernetes/kube_conf.c b/plugins/filter_kubernetes/kube_conf.c index eaf760fed4b..73e73495e92 100644 --- a/plugins/filter_kubernetes/kube_conf.c +++ b/plugins/filter_kubernetes/kube_conf.c @@ -243,11 +243,6 @@ void flb_kube_conf_destroy(struct flb_kube *ctx) if (ctx->kube_api_upstream) { flb_upstream_destroy(ctx->kube_api_upstream); } - - if (ctx->aws_pod_association_tls) { - flb_tls_destroy(ctx->aws_pod_association_tls); - } - if (ctx->aws_pod_association_upstream) { flb_upstream_destroy(ctx->aws_pod_association_upstream); } @@ -256,6 +251,10 @@ void flb_kube_conf_destroy(struct flb_kube *ctx) flb_free(ctx->platform); } + if (ctx->aws_pod_association_tls) { + flb_tls_destroy(ctx->aws_pod_association_tls); + } + #ifdef FLB_HAVE_TLS if (ctx->tls) { flb_tls_destroy(ctx->tls);