]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crush: fix memory leak 25959/head
authorxie xingguo <xie.xingguo@zte.com.cn>
Tue, 15 Jan 2019 08:23:26 +0000 (16:23 +0800)
committerxie xingguo <xie.xingguo@zte.com.cn>
Tue, 15 Jan 2019 08:23:26 +0000 (16:23 +0800)
If we remove the last item of bucket, there should still be
one final entry in the __weights__ field of __weight_set__.
Free the corresponding memory before we __null__ the pointer.

Signed-off-by: xie xingguo <xie.xingguo@zte.com.cn>
src/crush/CrushWrapper.cc

index 0fda4ee89d40a194e3bbb1b41cf413497706894e..7a323ca0390341b24afc82faa1b46ea52fb5814f 100644 (file)
@@ -2440,6 +2440,7 @@ int CrushWrapper::bucket_remove_item(crush_bucket *bucket, int item)
        weight_set->weights = (__u32*)realloc(weight_set->weights,
                                              new_size * sizeof(__u32));
       } else {
+        free(weight_set->weights);
        weight_set->weights = NULL;
       }
       weight_set->size = new_size;
@@ -2451,6 +2452,7 @@ int CrushWrapper::bucket_remove_item(crush_bucket *bucket, int item)
       if (new_size) {
        arg->ids = (__s32 *)realloc(arg->ids, new_size * sizeof(__s32));
       } else {
+        free(arg->ids);
        arg->ids = NULL;
       }
       arg->ids_size = new_size;