From cca69f2a5dcd2a30be7cb4fed767f522c0ee371f Mon Sep 17 00:00:00 2001 From: mumumu Date: Wed, 18 Nov 2026 05:01:59 +0800 Subject: [PATCH] fix(mag_bias_estimator): return after cleanup in the stop path (#29792) Run() calls exit_and_cleanup(desc) when should_exit() is set. That deletes the object, but Run() then continues to use _vehicle_status_sub, so the stop path reads freed memory. Add the missing return. Reproduced with an ASan SITL build: ERROR: AddressSanitizer: heap-use-after-free ... READ of size 8 #0 uORB::Subscription::subscribe() platforms/common/uORB/Subscription.cpp:48 #1 uORB::Subscription::updated() platforms/common/uORB/Subscription.hpp:133 #2 mag_bias_estimator::MagBiasEstimator::Run() MagBiasEstimator.cpp:84 freed by: MagBiasEstimator::~MagBiasEstimator() Trigger: 'mag_bias_estimator start', then 'mag_bias_estimator stop'. Assisted-by: deepseek Signed-off-by: Summermu <23356722+Summermu@users.noreply.github.com> --- src/modules/mag_bias_estimator/MagBiasEstimator.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/modules/mag_bias_estimator/MagBiasEstimator.cpp b/src/modules/mag_bias_estimator/MagBiasEstimator.cpp index 12360f1d4d2..c7dfba5d2d9 100644 --- a/src/modules/mag_bias_estimator/MagBiasEstimator.cpp +++ b/src/modules/mag_bias_estimator/MagBiasEstimator.cpp @@ -81,6 +81,7 @@ void MagBiasEstimator::Run() if (should_exit()) { ScheduleClear(); exit_and_cleanup(desc); + return; } if (_vehicle_status_sub.updated()) {