From: xiexingguo <258156334@qq.com> Date: Mon, 14 Dec 2015 07:42:38 +0000 (+0800) Subject: OSD: fix null pointer access and race condition X-Git-Tag: v10.0.3~152^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d9144481fd00aa120a57d24a198c88f87b77bdc8;p=ceph.git 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 --- 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()) {