From de2cd0960c70e42b8c12682e69af71a77a69a515 Mon Sep 17 00:00:00 2001 From: Gleb Chesnokov Date: Tue, 20 Oct 2026 16:09:40 +0300 Subject: [PATCH] scst_event: Trace the event request being freed Coccinelle iterators/use_after_iter.cocci reports the following diagnostic in scst_event_disallow_event (message wrapped): scst/src/scst_event.c:750:38-39: ERROR: invalid reference to the index variable of the iterator on line 731 After the disallow loop, e is the exhausted list iterator. The following TRACE_MEM uses e even though the allocation about to be freed is event_entry. Log event_entry instead so the trace names the allocation passed to kfree immediately afterwards. This fixes the diagnostic and the misleading trace address; the lookup, list removal and allocation lifetime are unchanged. --- scst/src/scst_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scst/src/scst_event.c b/scst/src/scst_event.c index 72fd0a52b..1aa3fed17 100644 --- a/scst/src/scst_event.c +++ b/scst/src/scst_event.c @@ -747,7 +747,7 @@ static int scst_event_disallow_event(struct scst_event_priv *priv, void __user * res = 0; } - TRACE_MEM("Deleting event entry %p", e); + TRACE_MEM("Deleting event entry %p", event_entry); kfree(event_entry); out: