From 667fb7258ce85f7a599533f1c5cb93e4dfe949ed Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 19 Oct 2012 09:09:53 -0700 Subject: [PATCH] mds: fix coverity warnings on NULL deref 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 > &, std::pair)". [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 > &, std::pair)". [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 > &, int)". [show details] Signed-off-by: Sage Weil --- src/mds/journal.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mds/journal.cc b/src/mds/journal.cc index 0de3f397f46bb..aea6c765c83e5 100644 --- a/src/mds/journal.cc +++ b/src/mds/journal.cc @@ -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(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 bounds; mds->mdcache->get_ambiguous_import_bounds(base, bounds); mds->mdcache->adjust_bounded_subtree_auth(dir, bounds, CDIR_AUTH_UNDEF); -- 2.39.5