Skip to content

Commit

Permalink
drivers/rpmsg: replace metal_list_for_each to safety version
Browse files Browse the repository at this point in the history
replace metal_list_for_each to safety version to avoid invalid access to deleted node in destory flow

Signed-off-by: chao an <[email protected]>
  • Loading branch information
anchao committed Sep 25, 2024
1 parent 73b7128 commit 2d3ae01
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/rpmsg/rpmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ void rpmsg_ns_bind(FAR struct rpmsg_device *rdev,
FAR void *cb_priv = cb->priv;

nxrmutex_unlock(&g_rpmsg_lock);
DEBUGASSERT(ns_bind != NULL);

ns_bind(rdev, cb_priv, name, dest);
return;
}
Expand Down Expand Up @@ -448,7 +448,7 @@ void rpmsg_device_destory(FAR struct rpmsg_s *rpmsg)
/* Broadcast device_destroy to all registers */

nxrmutex_lock(&g_rpmsg_lock);
metal_list_for_each(&g_rpmsg_cb, node)
metal_list_for_each_safe(&g_rpmsg_cb, tmp, node)
{
FAR struct rpmsg_cb_s *cb =
metal_container_of(node, struct rpmsg_cb_s, node);
Expand Down

0 comments on commit 2d3ae01

Please sign in to comment.