From: Sage Weil Date: Tue, 16 Feb 2021 21:50:18 +0000 (-0500) Subject: mon/ConfigMap: fix stray option leak X-Git-Tag: v15.2.13~13^2~16^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F40298%2Fhead;p=ceph.git mon/ConfigMap: fix stray option leak The const Option* needs to remain alive only until the next clear(). Keep the reference in ConfigMap and clean it up then. Signed-off-by: Sage Weil (cherry picked from commit 9397a46aec88e287d56a6286ed4319f65d9c1f31) Fixes: https://tracker.ceph.com/issues/48381 Conflicts: src/mon/ConfigMap.h: trivial resolution --- diff --git a/src/mon/ConfigMap.h b/src/mon/ConfigMap.h index 17b52af1d1d1..9c0a2a9f2676 100644 --- a/src/mon/ConfigMap.h +++ b/src/mon/ConfigMap.h @@ -99,6 +99,7 @@ struct ConfigMap { Section global; std::map by_type; std::map by_id; + std::list> stray_options; Section *find_section(const std::string& name) { if (name == "global") { @@ -118,6 +119,7 @@ struct ConfigMap { global.clear(); by_type.clear(); by_id.clear(); + stray_options.clear(); } void dump(Formatter *f) const; std::map> generate_entity_map( diff --git a/src/mon/ConfigMonitor.cc b/src/mon/ConfigMonitor.cc index 31b459611a5b..5ef80e700399 100644 --- a/src/mon/ConfigMonitor.cc +++ b/src/mon/ConfigMonitor.cc @@ -756,8 +756,10 @@ void ConfigMonitor::load_config() } if (!opt) { dout(10) << __func__ << " unrecognized option '" << name << "'" << dendl; - opt = new Option(name, Option::TYPE_STR, Option::LEVEL_UNKNOWN); - // FIXME: this will be leaked! + config_map.stray_options.push_back( + std::unique_ptr