From c887e875a456130e98071bcdf59a180c9cc4c646 Mon Sep 17 00:00:00 2001 From: LiuYangkuan Date: Mon, 11 Jun 2018 11:51:16 -0400 Subject: [PATCH] client: fix bug #24491 _ll_drop_pins may access invalid iterator Fixes: https://tracker.ceph.com/issues/24491 Signed-off-by: Liu Yangkuan (cherry picked from commit 97188fef8596f098aa43aa745a217b40a6c29ea4) --- src/client/Client.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/client/Client.cc b/src/client/Client.cc index 3167ddae0eaf..51f79838c717 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -10464,6 +10464,7 @@ int Client::_ll_put(Inode *in, int num) void Client::_ll_drop_pins() { ldout(cct, 10) << __func__ << dendl; + std::set to_be_put; //this set will be deconstructed item by item when exit ceph::unordered_map::iterator next; for (ceph::unordered_map::iterator it = inode_map.begin(); it != inode_map.end(); @@ -10471,8 +10472,10 @@ void Client::_ll_drop_pins() Inode *in = it->second; next = it; ++next; - if (in->ll_ref) + if (in->ll_ref){ + to_be_put.insert(in); _ll_put(in, in->ll_ref); + } } } -- 2.47.3