From: Danny Al-Gaaf Date: Fri, 10 May 2013 13:28:32 +0000 (+0200) Subject: mds/MDCache.cc: fix dereference NULL pointer X-Git-Tag: v0.63~41^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=447f318619adb369748e80ca0ef5009a8c4f71a0;p=ceph.git mds/MDCache.cc: fix dereference NULL pointer Fix possible NULL pointer dereference. Change return value of CInode::get_dirfrag() to return NULL instead of 0 since it's a pointer returned. CID 716991 Dereference null return value (CWE-478) Signed-off-by: Danny Al-Gaaf --- diff --git a/src/mds/CInode.h b/src/mds/CInode.h index a3fe3cf62884..7c63593c73cc 100644 --- a/src/mds/CInode.h +++ b/src/mds/CInode.h @@ -332,7 +332,7 @@ public: //assert(g_conf->debug_mds < 2 || dirfragtree.is_leaf(fg)); // performance hack FIXME return dirfrags[fg]; } else - return 0; + return NULL; } bool get_dirfrags_under(frag_t fg, list& ls); CDir* get_approx_dirfrag(frag_t fg); diff --git a/src/mds/MDCache.cc b/src/mds/MDCache.cc index 55ddf874776a..094aefdf5563 100644 --- a/src/mds/MDCache.cc +++ b/src/mds/MDCache.cc @@ -10082,7 +10082,8 @@ CDir *MDCache::force_dir_fragment(CInode *diri, frag_t fg) src.push_back(pdir); adjust_dir_fragments(diri, src, parent, split, result, waiters, true); dir = diri->get_dirfrag(fg); - dout(10) << "force_dir_fragment result " << *dir << dendl; + if (dir) + dout(10) << "force_dir_fragment result " << *dir << dendl; return dir; } if (parent == frag_t())