From: Danny Al-Gaaf Date: Fri, 13 Oct 2017 21:56:52 +0000 (+0200) Subject: osd/OSDMap.cc: fix potential null pointer deref X-Git-Tag: v13.0.1~358^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bc7cf704587057dbb4967d167247bccb9d48dfe2;p=ceph.git osd/OSDMap.cc: fix potential null pointer deref Use the same logic as in OSDMap::pg_to_raw_up(). Fix for: [src/osd/OSDMap.cc:2071] -> [src/osd/OSDMap.cc:2077]: (warning) Either the condition 'if(primary)' is redundant or there is possible null pointer dereference: primary. Signed-off-by: Danny Al-Gaaf --- diff --git a/src/osd/OSDMap.cc b/src/osd/OSDMap.cc index 2d87ffe4760c..fc829dde6998 100644 --- a/src/osd/OSDMap.cc +++ b/src/osd/OSDMap.cc @@ -2068,14 +2068,16 @@ void OSDMap::_get_temp_osds(const pg_pool_t& pool, pg_t pg, void OSDMap::pg_to_raw_osds(pg_t pg, vector *raw, int *primary) const { - *primary = -1; - raw->clear(); const pg_pool_t *pool = get_pg_pool(pg.pool()); - if (!pool) + if (!pool) { + if (primary) + *primary = -1; + if (raw) + raw->clear(); return; + } _pg_to_raw_osds(*pool, pg, raw, NULL); - if (primary) - *primary = _pick_primary(*raw); + *primary = _pick_primary(*raw); } void OSDMap::pg_to_raw_up(pg_t pg, vector *up, int *primary) const