All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/rockchip: use the safe iterator when removing device links
@ 2026-11-04  2:53 ` Wentao Liang
  0 siblings, 0 replies; 5+ messages in thread
From: Wentao Liang @ 2026-11-04  2:53 UTC (permalink / raw)
  To: Sandy Huang, Heiko Stübner, Andy Yan, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter
  Cc: dri-devel, linux-rockchip, linux-arm-kernel

rockchip_drm_match_remove() walks dev->links.consumers and calls
device_link_del() for every entry.  That drops the link's reference and,
once it reaches zero, __device_link_del() removes the link from the
device link lists and schedules the release of the link object.

list_for_each_entry() still reads link->s_node after the loop body to
find the next entry, so it accesses a link that has already been
released.  Use list_for_each_entry_safe() so that the next entry is
loaded before the current link is deleted.

Fixes: 7d4e981d41e3 ("drm/rockchip: Add device links for master and components")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/gpu/drm/rockchip/rockchip_drm_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
index 3099408e9d05..9edfe4db9393 100644
--- a/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
+++ b/drivers/gpu/drm/rockchip/rockchip_drm_drv.c
@@ -356,9 +356,9 @@ int rockchip_drm_endpoint_is_subdriver(struct device_node *ep)
 
 static void rockchip_drm_match_remove(struct device *dev)
 {
-	struct device_link *link;
+	struct device_link *link, *tmp;
 
-	list_for_each_entry(link, &dev->links.consumers, s_node)
+	list_for_each_entry_safe(link, tmp, &dev->links.consumers, s_node)
 		device_link_del(link);
 }
 
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-11-05 15:54 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-04  2:53 [PATCH] drm/rockchip: use the safe iterator when removing device links Wentao Liang
2026-11-04  2:53 ` Wentao Liang
2026-11-04  7:10 ` Krzysztof Kozlowski
2026-11-04  7:10   ` Krzysztof Kozlowski
2026-11-05 15:54 ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.