Spdk/module/bdev
Nick Connolly e7c019874c module/bdev/nvme: improve portability
In nvme_bdev_ctrlr_create, calloc will be called with a zero size
allocation request if the number of namespaces is zero. The behaviour
is implementation defined if the size of the space requested is zero -
calloc will either return a pointer that mustn't be dereferenced, or
NULL. If NULL is returned, the nvme_bdev_ctrlr_create will fail.

Only call calloc if there are a non-zero number of namespaces.
Otherwise, leave the namespaces pointer with a NULL value. All
references to namespaces[] are either known to be safe, or occur
in the context of looping through the namespaces which will be
skipped if the count is zero. The exception to this is in
vbdev_opal_create, where an assert has been added to match
equivalent code in bdev_ocssd_create_bdev.

Tested by running unit tests on a system that returns a null pointer
for a zero size allocation.

Signed-off-by: Nick Connolly <nick.connolly@mayadata.io>
Change-Id: I058b0683fd9b3a20bf90e54db93ca48b9bb4e40e
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/6551
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI
Community-CI: Mellanox Build Bot
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: sunshihao <sunshihao@huawei.com>
Reviewed-by: Aleksey Marchuk <alexeymar@mellanox.com>
2021-02-25 10:25:20 +00:00
..
aio so_ver: increase all major versions 2021-02-05 14:43:47 +00:00
compress so_ver: increase all major versions 2021-02-05 14:43:47 +00:00
crypto so_ver: increase all major versions 2021-02-05 14:43:47 +00:00
delay so_ver: increase all major versions 2021-02-05 14:43:47 +00:00
error so_ver: increase all major versions 2021-02-05 14:43:47 +00:00
ftl so_ver: increase all major versions 2021-02-05 14:43:47 +00:00
gpt so_ver: increase all major versions 2021-02-05 14:43:47 +00:00
iscsi so_ver: increase all major versions 2021-02-05 14:43:47 +00:00
lvol so_ver: increase all major versions 2021-02-05 14:43:47 +00:00
malloc so_ver: increase all major versions 2021-02-05 14:43:47 +00:00
null so_ver: increase all major versions 2021-02-05 14:43:47 +00:00
nvme module/bdev/nvme: improve portability 2021-02-25 10:25:20 +00:00
ocf bdev/ocf: Handle memory error properly 2021-02-24 13:06:12 +00:00
passthru so_ver: increase all major versions 2021-02-05 14:43:47 +00:00
pmem so_ver: increase all major versions 2021-02-05 14:43:47 +00:00
raid so_ver: increase all major versions 2021-02-05 14:43:47 +00:00
rbd so_ver: increase all major versions 2021-02-05 14:43:47 +00:00
split so_ver: increase all major versions 2021-02-05 14:43:47 +00:00
uring so_ver: increase all major versions 2021-02-05 14:43:47 +00:00
virtio so_ver: increase all major versions 2021-02-05 14:43:47 +00:00
zone_block so_ver: increase all major versions 2021-02-05 14:43:47 +00:00
Makefile bdev: move bdev_rpc library contents 2020-09-25 11:43:42 +00:00