From d8138c80d1e53526b97be748e2bbe003d6b180bb Mon Sep 17 00:00:00 2001 From: Danny Al-Gaaf Date: Tue, 14 Jul 2015 09:14:56 +0200 Subject: [PATCH] mon/Monitor.cc: fix potential null deref Add assert to MonSessionMap::new_session(). Fix for: CID 1128408 (#1 of 1): Dereference before null check (REVERSE_INULL) check_after_deref: Null-checking s suggests that it may be null, but it has already been dereferenced on all paths leading to the check. Signed-off-by: Danny Al-Gaaf --- src/mon/Monitor.cc | 1 + src/mon/Session.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 3428feb1bb7..0e2068b9890 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -3465,6 +3465,7 @@ void Monitor::dispatch(MonOpRequestRef op) dout(10) << "do not have session, making new one" << dendl; s = session_map.new_session(m->get_source_inst(), m->get_connection().get()); + assert(s); m->get_connection()->set_priv(s->get()); dout(10) << "ms_dispatch new session " << s << " for " << s->inst << dendl; op->set_session(s); diff --git a/src/mon/Session.h b/src/mon/Session.h index 4a19d84a4fb..e4cfed09325 100644 --- a/src/mon/Session.h +++ b/src/mon/Session.h @@ -123,6 +123,7 @@ struct MonSessionMap { MonSession *new_session(const entity_inst_t& i, Connection *c) { MonSession *s = new MonSession(i, c); + assert(s); sessions.push_back(&s->item); if (i.name.is_osd()) by_osd.insert(pair(i.name.num(), s)); -- 2.47.3