From d9144481fd00aa120a57d24a198c88f87b77bdc8 Mon Sep 17 00:00:00 2001 From: xiexingguo <258156334@qq.com> Date: Mon, 14 Dec 2015 15:42:38 +0800 Subject: [PATCH] OSD: fix null pointer access and race condition We are risking of accessing a null osdmap pointer when we failed to handle an osdmap message due to network error. Also, it is not safe to change failure_pending without protection of hearbeat_lock. Fixes: #14072 Signed-off-by: xie xingguo --- src/osd/OSD.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index 1d0ca9c57f21..f38695ab74a5 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -6633,16 +6633,17 @@ void OSD::handle_osd_map(MOSDMap *m) osdmap_subscribe(osdmap->get_epoch()+1, false); } else if (do_shutdown) { - osd_lock.Unlock(); - shutdown(); if (network_error) { + Mutex::Locker l(heartbeat_lock); map>::iterator it = failure_pending.begin(); while (it != failure_pending.end()) { dout(10) << "handle_osd_ping canceling in-flight failure report for osd." << it->first << dendl; send_still_alive(osdmap->get_epoch(), it->second.second); failure_pending.erase(it++); } - } + } + osd_lock.Unlock(); + shutdown(); osd_lock.Lock(); } else if (is_preboot()) { -- 2.47.3