From 055020ce80b1f08d258b4c023bf5465ed7a46034 Mon Sep 17 00:00:00 2001 From: Patrick Donnelly Date: Tue, 12 Sep 2017 14:31:18 -0700 Subject: [PATCH] mds: check if waiting is allocated before use This prevents accidental allocation of the map. Also, privatize the variable to protect from this in child classes. Signed-off-by: Patrick Donnelly --- src/mds/MDSCacheObject.h | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/mds/MDSCacheObject.h b/src/mds/MDSCacheObject.h index 96493d4dd8cf7..7f12e80953f9d 100644 --- a/src/mds/MDSCacheObject.h +++ b/src/mds/MDSCacheObject.h @@ -301,7 +301,7 @@ protected: // --------------------------------------------- // waiting - protected: + private: alloc_ptr>> waiting; static uint64_t last_wait_seq; @@ -310,13 +310,13 @@ protected: if (!min) { min = mask; while (min & (min-1)) // if more than one bit is set - min &= min-1; // clear LSB + min &= min-1; // clear LSB } - for (auto p = waiting->lower_bound(min); - p != waiting->end(); - ++p) { - if (p->first & mask) return true; - if (p->first > mask) return false; + if (waiting) { + for (auto p = waiting->lower_bound(min); p != waiting->end(); ++p) { + if (p->first & mask) return true; + if (p->first > mask) return false; + } } return false; } @@ -339,7 +339,7 @@ protected: } virtual void take_waiting(uint64_t mask, std::list& ls) { - if (waiting->empty()) return; + if (!waiting || waiting->empty()) return; // process ordered waiters in the same order that they were added. std::map ordered_waiters; -- 2.39.5