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: yidong0635 <dongx.yi@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/458736
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
yidong0635 2019-06-20 09:11:27 -04:00 committed by Ben Walker
parent c7abeb33b5
commit c947e87e46

View File

@ -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;