bdev/raid: fix a warning of freed memory

Compilation Warning on fedora30.
In file included from bdev_raid_ut.c:38:
spdk/lib/bdev/raid/bdev_raid.c:325:11: warning:
Use of memory after it is freed. raid_ch->base_channel[pd_idx],
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is related to issue #822.

Change-Id: I6432772fb38ca02bc4f0a02a36ed3fe61b8607c7
Signed-off-by: Hailiang Wang <hailiangx.e.wang@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/460069
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: yidong0635 <dongx.yi@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
This commit is contained in:
Hailiang Wang 2019-07-02 14:42:19 +08:00 committed by Darek Stojaczyk
parent 6035ec86e6
commit 5926236661

View File

@ -115,6 +115,7 @@ raid_bdev_create_cb(void *io_device, void *ctx_buf)
spdk_put_io_channel(raid_ch->base_channel[j]);
}
free(raid_ch->base_channel);
raid_ch->base_channel = NULL;
SPDK_ERRLOG("Unable to create io channel for base bdev\n");
return -ENOMEM;
}
@ -320,6 +321,8 @@ raid_bdev_submit_rw_request(struct spdk_bdev_io *bdev_io, uint64_t start_strip)
* bdev lba, base bdev child io length in blocks, buffer, completion
* function and function callback context
*/
assert(raid_ch != NULL);
assert(raid_ch->base_channel);
if (bdev_io->type == SPDK_BDEV_IO_TYPE_READ) {
ret = spdk_bdev_readv_blocks(raid_bdev->base_bdev_info[pd_idx].desc,
raid_ch->base_channel[pd_idx],