From d998c33a3d0c781bdf97d47c76412c03b21b70c6 Mon Sep 17 00:00:00 2001 From: wangchen Date: Tue, 13 Aug 2024 19:49:33 +0800 Subject: [PATCH] netlink:add tls cleanup protection to protect waitsem in netlink_get_response Signed-off-by: wangchen --- net/netlink/netlink.h | 2 +- net/netlink/netlink_conn.c | 3 +++ net/netlink/netlink_notifier.c | 3 ++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/net/netlink/netlink.h b/net/netlink/netlink.h index b12cf9647a3eb..f411e2a0b6ede 100644 --- a/net/netlink/netlink.h +++ b/net/netlink/netlink.h @@ -379,7 +379,7 @@ int netlink_notifier_setup(worker_t worker, FAR struct netlink_conn_s *conn, * ****************************************************************************/ -void netlink_notifier_teardown(FAR struct netlink_conn_s *conn); +void netlink_notifier_teardown(FAR void *conn); /**************************************************************************** * Name: netlink_notifier_signal diff --git a/net/netlink/netlink_conn.c b/net/netlink/netlink_conn.c index f68d79791d7fc..5f6f57b6e183e 100644 --- a/net/netlink/netlink_conn.c +++ b/net/netlink/netlink_conn.c @@ -39,6 +39,7 @@ #include #include #include +#include #include "utils/utils.h" #include "netlink/netlink.h" @@ -451,7 +452,9 @@ int netlink_get_response(FAR struct netlink_conn_s *conn, { /* Wait for a response to be queued */ + tls_cleanup_push(tls_get_info(), netlink_notifier_teardown, conn); ret = net_sem_wait(&waitsem); + tls_cleanup_pop(tls_get_info(), 0); } /* Clean-up the semaphore */ diff --git a/net/netlink/netlink_notifier.c b/net/netlink/netlink_notifier.c index 782a9a6f6507c..8ce52dabd9e33 100644 --- a/net/netlink/netlink_notifier.c +++ b/net/netlink/netlink_notifier.c @@ -95,8 +95,9 @@ int netlink_notifier_setup(worker_t worker, FAR struct netlink_conn_s *conn, * ****************************************************************************/ -void netlink_notifier_teardown(FAR struct netlink_conn_s *conn) +void netlink_notifier_teardown(FAR void *arg) { + FAR struct netlink_conn_s *conn = arg; DEBUGASSERT(conn != NULL); /* This is just a simple wrapper around work_notifier_teardown(). */