]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/internal.cc: check earlier for null pointer
authorDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Wed, 4 Jun 2014 21:22:18 +0000 (23:22 +0200)
committerDanny Al-Gaaf <danny.al-gaaf@bisect.de>
Wed, 4 Jun 2014 21:22:18 +0000 (23:22 +0200)
Fix potential null ponter deref, move check for 'order != NULL'
to the beginning of the function to prevent a) deref in ldout() call
and b) to leave function as early as possible if check fails.

[src/librbd/internal.cc:843] -> [src/librbd/internal.cc:865]: (warning)
 Possible null pointer dereference: order - otherwise it is redundant
 to check it against null.

Signed-off-by: Danny Al-Gaaf <danny.al-gaaf@bisect.de>
src/librbd/internal.cc

index 1d0e43f4ac44494d06b479d4c5e8eafd1031fd1e..2f4a88eb0f8b860c5006a2c2d98f2f91eeea33cf 100644 (file)
@@ -837,6 +837,9 @@ reprotect_and_return_err:
             bool old_format, uint64_t features, int *order,
             uint64_t stripe_unit, uint64_t stripe_count)
   {
+    if (!order)
+      return -EINVAL;
+
     CephContext *cct = (CephContext *)io_ctx.cct();
     ldout(cct, 20) << "create " << &io_ctx << " name = " << imgname
                   << " size = " << size << " old_format = " << old_format
@@ -862,9 +865,6 @@ reprotect_and_return_err:
       return -EEXIST;
     }
 
-    if (!order)
-      return -EINVAL;
-
     if (!*order)
       *order = cct->_conf->rbd_default_order;
     if (!*order)