]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commit
crush: no need to call malloc is request is zero 36729/head
authorChangcheng Liu <changcheng.liu@aliyun.com>
Thu, 20 Aug 2020 02:10:35 +0000 (10:10 +0800)
committerChangcheng Liu <changcheng.liu@aliyun.com>
Thu, 20 Aug 2020 03:33:25 +0000 (11:33 +0800)
commit4071dde70ce26c6058b72b3556ba5b8404579bb6
treeff6ff195f1a6524b25cac441b42a40a173e9bb99
parent58dbf9572576f42e33a932153ecc9d68b4c9ee1c
crush: no need to call malloc is request is zero

1. malloc(0) depends on libary's behavior:
https://pubs.opengroup.org/onlinepubs/009695399/functions/malloc.html
2. There's below frame path which call malloc(0)
   # build_simple_crush_map
   # |--> crush.add_bucket(0, 0, CRUSH_HASH_DEFAULT, root_type, 0, NULL, NULL, &rootid);
   #      |--> crush_bucket *b = crush_make_bucket(crush, alg, hash, type, size, items, weights);
   #           |--> crush_make_straw2_bucket(map, hash, type, size, items, weights);
   #                |--> bucket->h.items = malloc(sizeof(__s32)*size);
   #           |--> ceph_assert(b);
   If the library return NULL(malloc(0)), ceph_assert(b) will trigger abort

Signed-off-by: Changcheng Liu <changcheng.liu@aliyun.com>
src/crush/builder.c