From: Patrick Donnelly Date: Tue, 12 Sep 2017 21:31:18 +0000 (-0700) Subject: mds: check if waiting is allocated before use X-Git-Tag: v12.2.1~30^2~7 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=97fdc68e029ed1567eff7c5d13a6c1c29bfe5d33;p=ceph.git 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 (cherry picked from commit 055020ce80b1f08d258b4c023bf5465ed7a46034) --- diff --git a/src/mds/MDSCacheObject.h b/src/mds/MDSCacheObject.h index 96493d4dd8c..7f12e80953f 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;