diff --git a/include/fluent-bit/flb_kernel.h b/include/fluent-bit/flb_kernel.h index 21a9d05c808..116b4a79d9a 100644 --- a/include/fluent-bit/flb_kernel.h +++ b/include/fluent-bit/flb_kernel.h @@ -35,5 +35,6 @@ struct flb_kernel { }; struct flb_kernel *flb_kernel_info(); +void flb_kernel_destroy(struct flb_kernel *kernel); #endif diff --git a/src/flb_config.c b/src/flb_config.c index 459ff8197dd..a0feb73b3f2 100644 --- a/src/flb_config.c +++ b/src/flb_config.c @@ -393,8 +393,7 @@ void flb_config_exit(struct flb_config *config) } if (config->kernel) { - flb_free(config->kernel->s_version.data); - flb_free(config->kernel); + flb_kernel_destroy(config->kernel); } /* release resources */ diff --git a/src/flb_kernel.c b/src/flb_kernel.c index 5e5fa886abb..d29ba922fe9 100644 --- a/src/flb_kernel.c +++ b/src/flb_kernel.c @@ -147,3 +147,15 @@ struct flb_kernel *flb_kernel_info() } #endif + +void flb_kernel_destroy(struct flb_kernel *kernel) +{ + if (kernel == NULL) { + return; + } + + if (kernel->s_version.data) { + flb_free(kernel->s_version.data); + } + flb_free(kernel); +}