From 840ed4a18d6a0124bfa8deb03b6b759c64922ded Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Tue, 13 Jun 2017 13:17:28 +0200 Subject: [PATCH] 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 --- src/rgw/rgw_bucket.cc | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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; -- 2.47.3