Commit 8db5ff2b authored by wuzhouhui's avatar wuzhouhui Committed by Jim Harris
Browse files

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: default avatarwuzhouhui <wuzhouhui@kingsoft.com>
Reviewed-on: https://review.gerrithub.io/437292


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent 3a4185be
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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;
	}