ceph: Fix oops when handling mdsmap that decreases max_mds
authorYan, Zheng <zheng.z.yan@intel.com>
Thu, 20 Sep 2012 09:42:25 +0000 (17:42 +0800)
committerAlex Elder <elder@inktank.com>
Mon, 1 Oct 2012 19:30:54 +0000 (14:30 -0500)
When i >= newmap->m_max_mds, ceph_mdsmap_get_addr(newmap, i) return
NULL. Passing NULL to memcmp() triggers oops.

Signed-off-by: Yan, Zheng <zheng.z.yan@intel.com>
Signed-off-by: Sage Weil <sage@inktank.com>
fs/ceph/mds_client.c

index a5a735422aa7a43e5e2d6022c81402f739a1b660..1bcf712655d90a6001db4e8de8e86cfa3a70187d 100644 (file)
@@ -2625,7 +2625,8 @@ static void check_new_map(struct ceph_mds_client *mdsc,
                     ceph_mdsmap_is_laggy(newmap, i) ? " (laggy)" : "",
                     session_state_name(s->s_state));
 
-               if (memcmp(ceph_mdsmap_get_addr(oldmap, i),
+               if (i >= newmap->m_max_mds ||
+                   memcmp(ceph_mdsmap_get_addr(oldmap, i),
                           ceph_mdsmap_get_addr(newmap, i),
                           sizeof(struct ceph_entity_addr))) {
                        if (s->s_state == CEPH_MDS_SESSION_OPENING) {