From b25b1f92ca88aa9f268c93d0d7f66efc0ebf840b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dirk=20M=C3=BCller?= Date: Tue, 25 Oct 2022 23:33:14 +0200 Subject: [PATCH] Avoid double free on deinit_thermal() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit init_thermal() calls deinit_thermal() on error condition, as well as main() calls deinit_thermal() again, causing a double-free. Signed-off-by: Dirk Müller --- thermal.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/thermal.c b/thermal.c index 64a9cdf..1d44104 100644 --- a/thermal.c +++ b/thermal.c @@ -506,8 +506,14 @@ static gboolean set_netlink_nonblocking(void) void deinit_thermal(void) { - nl_cb_put(callback); - nl_socket_free(sock); + if (callback) { + nl_cb_put(callback); + callback = NULL; + } + if (sock) { + nl_socket_free(sock); + sock = NULL; + } } /*