]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
osd/OSDMap.cc: fix potential null pointer deref
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Fri, 13 Oct 2017 21:56:52 +0000 (23:56 +0200)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Wed, 25 Oct 2017 16:14:05 +0000 (18:14 +0200)
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 <danny.al-gaaf@bisect.de>
src/osd/OSDMap.cc

index 2d87ffe4760ca9f697a4c94af674dcaa584739cd..fc829dde69985a274bfc43327dd58f20b1eb136d 100644 (file)
@@ -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<int> *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<int> *up, int *primary) const