Commit c947e87e authored by yidong0635's avatar yidong0635 Committed by Ben Walker
Browse files

nvme/deallocated_value: Fix scanbuild error on fedora30 with GCC9.



Scanbuild error on fedora30 reports:
warning: Array access (via field 'write_buf') results in a null pointer dereference
                if (context->write_buf[i]) {

In deallocated_value.c, cleanup function be used at many places to deal with failed
cases even context->write_buf is  NULL, so add context->write_buf pointer check before
array data. I think context->read_buf is the same.

This is related to issue #822.

Change-Id: I33c685fd732da820c1dfc861eb991b92b41caa29
Signed-off-by: default avataryidong0635 <dongx.yi@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/458736


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent c7abeb33
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -395,12 +395,12 @@ cleanup(struct deallocate_context *context)
		ns_entry = next;
	}
	for (i = 0; i < NUM_BLOCKS; i++) {
		if (context->write_buf[i]) {
		if (context->write_buf && context->write_buf[i]) {
			spdk_dma_free(context->write_buf[i]);
		} else {
			break;
		}
		if (context->read_buf[i]) {
		if (context->read_buf && context->read_buf[i]) {
			spdk_dma_free(context->read_buf[i]);
		} else {
			break;