From: Radoslaw Zarzynski Date: Tue, 13 Jun 2017 11:17:28 +0000 (+0200) Subject: rgw: fix error handling in the link() method of RGWBucket. X-Git-Tag: v12.1.1~60^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F15669%2Fhead;p=ceph.git rgw: fix error handling in the link() method of RGWBucket. 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 --- diff --git a/src/rgw/rgw_bucket.cc b/src/rgw/rgw_bucket.cc index 97ddb192c2d0..794e9a9869cd 100644 --- a/src/rgw/rgw_bucket.cc +++ b/src/rgw/rgw_bucket.cc @@ -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;