Skip to content

Commit

Permalink
netlink:add tls cleanup protection to protect waitsem in netlink_get_…
Browse files Browse the repository at this point in the history
…response

Signed-off-by: wangchen <[email protected]>
  • Loading branch information
wangchen61698 committed Aug 20, 2024
1 parent fe2dc34 commit d998c33
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion net/netlink/netlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions net/netlink/netlink_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,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"
Expand Down Expand Up @@ -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 */
Expand Down
3 changes: 2 additions & 1 deletion net/netlink/netlink_notifier.c
Original file line number Diff line number Diff line change
Expand Up @@ -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(). */
Expand Down

0 comments on commit d998c33

Please sign in to comment.