From 6509cb85b3edba8194c2b3d7a505321eb9af785a Mon Sep 17 00:00:00 2001 From: Changwei Ye Date: Thu, 15 Oct 2026 10:07:18 +0800 Subject: [PATCH] osd: call deref_object_state on recheck_state mismatch in remove_object_from_state When recheck_state != *object_state, the old object_state reference should be released via deref_object_state() instead of raw ref_count--. Otherwise, if the old state has no remaining objects (object_count == 0) and this was its last reference, it would never be erased from pg.state_dict, leaking memory and state dictionary entries. --- src/osd/osd_primary.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/osd/osd_primary.cpp b/src/osd/osd_primary.cpp index 560eefc7..aeef0140 100644 --- a/src/osd/osd_primary.cpp +++ b/src/osd/osd_primary.cpp @@ -776,7 +776,7 @@ bool osd_t::remove_object_from_state(object_id & oid, pg_osd_set_state_t **objec { if (recheck_state) recheck_state->ref_count++; - (*object_state)->ref_count--; + deref_object_state(pg, object_state, true); *object_state = recheck_state; return false; } -- 2.47.3