From 1ec9c49d320ecf2ab415af904a89f13f8a61b612 Mon Sep 17 00:00:00 2001 From: Josh Durgin Date: Fri, 7 Jan 2022 13:37:13 -0500 Subject: [PATCH] mon/OSDMonitor: avoid null dereference if stats are not available Not confirmed yet whether this was the issue in the bug referenced below, however it's a necessary defensive check for the 'osd pool get-quota' command. All other uses of get_pool_stats() already handle this case. Related-to: https://tracker.ceph.com/issues/53740 Signed-off-by: Josh Durgin (cherry picked from commit 9c8392be33a574f15bc35b8f49e319af50d99e90) --- src/mon/OSDMonitor.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 927b8b8af92c2..e050cbe8feff9 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -6586,6 +6586,11 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op) } const pg_pool_t *p = osdmap.get_pg_pool(poolid); const pool_stat_t* pstat = mon.mgrstatmon()->get_pool_stat(poolid); + if (!pstat) { + ss << "no stats for pool '" << pool_name << "'"; + r = -ENOENT; + goto reply; + } const object_stat_sum_t& sum = pstat->stats.sum; if (f) { f->open_object_section("pool_quotas"); -- 2.39.5