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 authored and xiaoxiang781216 committed Sep 26, 2024
1 parent 06b3416 commit 4195851
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 4195851

Please sign in to comment.