]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon/Monitor.cc: fix potential null deref 5000/head
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Tue, 14 Jul 2015 07:14:56 +0000 (09:14 +0200)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Fri, 17 Jul 2015 08:50:46 +0000 (10:50 +0200)
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 <danny.al-gaaf@bisect.de>
src/mon/Monitor.cc
src/mon/Session.h

index 3428feb1bb7263761e47bf2271027f0e99176712..0e2068b9890b64473ee262fd4a714563fe76d52f 100644 (file)
@@ -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);
index 4a19d84a4fbcd6f273be6548a4a1022c942f120f..e4cfed09325093d8c982562561c0246b9da95b7b 100644 (file)
@@ -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<int,MonSession*>(i.name.num(), s));