]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: fix error handling in the link() method of RGWBucket. 15669/head
authorRadoslaw Zarzynski <rzarzynski@mirantis.com>
Tue, 13 Jun 2017 11:17:28 +0000 (13:17 +0200)
committerRadoslaw Zarzynski <rzarzynski@mirantis.com>
Tue, 13 Jun 2017 15:36:21 +0000 (17:36 +0200)
The recent Static Analysis for Ceph (linked 13 June 2017 on
ceph-devel) shows that the link() method of RGWBucket assigns
to a variable but doesn't use it later. The anomaly is caused
by lack of proper error handling. This commit rectifies it.

Fixes: http://tracker.ceph.com/issues/20279
Signed-off-by: Radoslaw Zarzynski <rzarzynski@mirantis.com>
src/rgw/rgw_bucket.cc

index 97ddb192c2d08dc546083a2f7c5f000b61a2ec9c..794e9a9869cd40d6e53f8441fa093c9e6b84c89a 100644 (file)
@@ -868,8 +868,9 @@ int RGWBucket::link(RGWBucketAdminOpState& op_state, std::string *err_msg)
     policy.encode(aclbl);
 
     r = store->system_obj_set_attr(NULL, obj, RGW_ATTR_ACL, aclbl, &objv_tracker);
-    if (r < 0)
+    if (r < 0) {
       return r;
+    }
 
     RGWAccessControlPolicy policy_instance;
     policy_instance.create_default(user_info.user_id, display_name);
@@ -879,10 +880,14 @@ int RGWBucket::link(RGWBucketAdminOpState& op_state, std::string *err_msg)
     string oid_bucket_instance = RGW_BUCKET_INSTANCE_MD_PREFIX + key;
     rgw_raw_obj obj_bucket_instance(root_pool, oid_bucket_instance);
     r = store->system_obj_set_attr(NULL, obj_bucket_instance, RGW_ATTR_ACL, aclbl, &objv_tracker);
+    if (r < 0) {
+      return r;
+    }
 
     r = rgw_link_bucket(store, user_info.user_id, bucket_info.bucket, real_time());
-    if (r < 0)
+    if (r < 0) {
       return r;
+    }
   }
 
   return 0;