From 354823e2efd8dd7ac47f4b8984b8e0fb06dc3b79 Mon Sep 17 00:00:00 2001 From: XiaoYang Chen <34237762+godesady@users.noreply.github.com> Date: Sat, 5 Sep 2026 03:25:32 +0800 Subject: [PATCH] fix(load_mon): add return code at module stop path (#28544) * fix uaf bug in load_mon module * fix(load_mon): end the perf cycle before deleting the module exit_and_cleanup() deletes this and frees _cycle_perf, so the elapsed counter has to be closed on the live object. Signed-off-by: Jacob Dahl --------- Signed-off-by: Jacob Dahl Co-authored-by: Jacob Dahl --- src/modules/load_mon/LoadMon.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/modules/load_mon/LoadMon.cpp b/src/modules/load_mon/LoadMon.cpp index 6194afed1b6..3e853e913c4 100644 --- a/src/modules/load_mon/LoadMon.cpp +++ b/src/modules/load_mon/LoadMon.cpp @@ -111,15 +111,16 @@ void LoadMon::Run() #endif + perf_end(_cycle_perf); + if (should_exit()) { ScheduleClear(); #if defined (__PX4_LINUX) fclose(_proc_fd); #endif exit_and_cleanup(desc); + return; } - - perf_end(_cycle_perf); } void LoadMon::cpuload()