]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: fix coverity warnings on NULL deref
authorSage Weil <sage@inktank.com>
Fri, 19 Oct 2012 16:09:53 +0000 (09:09 -0700)
committerSage Weil <sage@inktank.com>
Fri, 19 Oct 2012 16:09:53 +0000 (09:09 -0700)
Add asserts...

At (5): Function "MDCache::get_dirfrag(dirfrag_t)" returns null (checked 33 out of 39 times). [show details]
At (6): Assigning: "dir" = null return value from "MDCache::get_dirfrag(dirfrag_t)".
CID 717007 (#1 of 1): Dereference null return value (NULL_RETURNS)
At (7): Dereferencing a pointer that might be null "dir" when calling "MDCache::adjust_bounded_subtree_auth(CDir *, std::vector<dirfrag_t, std::allocator<dirfrag_t> > &, std::pair<int, int>)". [show details]

CID 717006 (#1 of 1): Dereference null return value (NULL_RETURNS)
At (5): Dereferencing a pointer that might be null "dir" when calling "MDCache::adjust_bounded_subtree_auth(CDir *, std::vector<dirfrag_t, std::allocator<dirfrag_t> > &, std::pair<int, int>)". [show details]

CID 717005 (#2 of 2): Dereference null return value (NULL_RETURNS)
At (22): Dereferencing a pointer that might be null "dir" when calling "MDCache::adjust_bounded_subtree_auth(CDir *, std::vector<dirfrag_t, std::allocator<dirfrag_t> > &, int)". [show details]

Signed-off-by: Sage Weil <sage@inktank.com>
src/mds/journal.cc

index 0de3f397f46bb2bb55039202621a293e44fc3831..aea6c765c83e58a1034b8de82979a673db462f2d 100644 (file)
@@ -1209,6 +1209,7 @@ void ESubtreeMap::replay(MDS *mds)
        p != subtrees.end();
        ++p) {
     CDir *dir = mds->mdcache->get_dirfrag(p->first);
+    assert(dir);
     if (ambiguous_subtrees.count(p->first)) {
       // ambiguous!
       mds->mdcache->add_ambiguous_import(p->first, p->second);
@@ -1322,6 +1323,7 @@ void EImportStart::replay(MDS *mds)
 
   // set auth partially to us so we don't trim it
   CDir *dir = mds->mdcache->get_dirfrag(base);
+  assert(dir);
   mds->mdcache->adjust_bounded_subtree_auth(dir, bounds, pair<int,int>(mds->get_nodeid(), mds->get_nodeid()));
 
   // open client sessions?
@@ -1348,10 +1350,11 @@ void EImportFinish::replay(MDS *mds)
 {
   if (mds->mdcache->have_ambiguous_import(base)) {
     dout(10) << "EImportFinish.replay " << base << " success=" << success << dendl;
-    if (success) 
+    if (success) {
       mds->mdcache->finish_ambiguous_import(base);
-    else {
+    else {
       CDir *dir = mds->mdcache->get_dirfrag(base);
+      assert(dir);
       vector<dirfrag_t> bounds;
       mds->mdcache->get_ambiguous_import_bounds(base, bounds);
       mds->mdcache->adjust_bounded_subtree_auth(dir, bounds, CDIR_AUTH_UNDEF);