netlink:add tls cleanup protection to protect waitsem in netlink_get_response

Signed-off-by: wangchen <wangchen41@xiaomi.com>
This commit is contained in:
wangchen 2024-08-13 19:49:33 +08:00 committed by Xiang Xiao
parent 807c3a16e3
commit 90e2395d6c
3 changed files with 6 additions and 2 deletions

View File

@ -385,7 +385,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

View File

@ -41,6 +41,7 @@
#include <nuttx/net/netconfig.h>
#include <nuttx/net/net.h>
#include <nuttx/net/netlink.h>
#include <nuttx/tls.h>
#include "utils/utils.h"
#include "netlink/netlink.h"
@ -533,7 +534,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 */

View File

@ -97,8 +97,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(). */