From f764aaf99844e486798d2e7943ea3985bcf90612 Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Mon, 21 Mar 2022 15:15:12 -0700 Subject: [PATCH] storaged: Fix double ownership for HealthInfoCallback. SharedRefBase objects can only be created via SharedRefBase::make, not std::make_shared. Otherwise there'll be a double-ownership problem. Test: TH Fixes: 225448524 Change-Id: I856677626cb146eb52a5b4a4562148e899d5a57b --- storaged/storaged.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/storaged/storaged.cpp b/storaged/storaged.cpp index fb855f750..8cc8b596e 100644 --- a/storaged/storaged.cpp +++ b/storaged/storaged.cpp @@ -153,7 +153,7 @@ void storaged_t::init_health_service() { mUidm.init(is_charger_on(status)); // register listener after init uid_monitor - aidl_health_callback = std::make_shared(&mUidm); + aidl_health_callback = ndk::SharedRefBase::make(&mUidm); ret = health->registerCallback(aidl_health_callback); if (!ret.isOk()) { LOG(WARNING) << "health: failed to register callback: " << ret.getDescription();