bdev: fix io_channel leaks on bdev channel creation failure

The underlying io_channel created by a bdev module
could be never freed in various cases due to missing
spdk_put_io_channel() calls.

Change-Id: If1aa736f67f0354c4f9dcdf61d3f1e6b859b4c48
Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/438803
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: wuzhouhui <wuzhouhui@kingsoft.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Darek Stojaczyk 2019-01-02 14:20:36 +01:00 committed by Jim Harris
parent 480b0b9ed8
commit ec5972cb0d

View File

@ -1818,6 +1818,7 @@ spdk_bdev_channel_create(void *io_device, void *ctx_buf)
mgmt_io_ch = spdk_get_io_channel(&g_bdev_mgr);
if (!mgmt_io_ch) {
spdk_put_io_channel(ch->channel);
return -1;
}
@ -1833,6 +1834,7 @@ spdk_bdev_channel_create(void *io_device, void *ctx_buf)
if (shared_resource == NULL) {
shared_resource = calloc(1, sizeof(*shared_resource));
if (shared_resource == NULL) {
spdk_put_io_channel(ch->channel);
spdk_put_io_channel(mgmt_io_ch);
return -1;
}