reduce: _allocate_vol_requests: set pointer to NULL after freed

If _allocate_vol_requests() failed, the caller will call
_init_load_cleanup() to free memory that _allocate_vol_requests()
already freed, and cause segment fault. Setting pointer to NULL keeps
_init_load_cleanup() is safe to free it again.

Change-Id: I9ad09eabf6b65350f174bd5a4faf5ee643cbd23f
Signed-off-by: wuzhouhui <wuzhouhui@kingsoft.com>
Reviewed-on: https://review.gerrithub.io/437292
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
wuzhouhui 2018-12-14 16:55:11 +08:00 committed by Jim Harris
parent 3a4185be19
commit 8db5ff2bdd

View File

@ -287,6 +287,7 @@ _allocate_vol_requests(struct spdk_reduce_vol *vol)
vol->request_mem = calloc(REDUCE_NUM_VOL_REQUESTS, sizeof(*req));
if (vol->request_mem == NULL) {
spdk_dma_free(vol->reqbufspace);
vol->reqbufspace = NULL;
return -ENOMEM;
}
@ -295,6 +296,8 @@ _allocate_vol_requests(struct spdk_reduce_vol *vol)
if (vol->buf_iov_mem == NULL) {
free(vol->request_mem);
spdk_dma_free(vol->reqbufspace);
vol->request_mem = NULL;
vol->reqbufspace = NULL;
return -ENOMEM;
}