Commit 34f66f23 authored by Daniel Verkamp's avatar Daniel Verkamp
Browse files

ut/nvme: add fatal asserts before dereferencing pointers



Make sure that req returned from the request allocation functions isn't
NULL before starting to check its fields.

Change-Id: I21869834148200f4bfd5065ebbc874041c559599
Signed-off-by: default avatarDaniel Verkamp <daniel.verkamp@intel.com>
Reviewed-on: https://review.gerrithub.io/375618


Tested-by: default avatarSPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 0269601f
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -397,6 +397,7 @@ test_nvme_allocate_request_null(void)
	 * Compare the req with the parmaters that we passed in
	 * as well as what the function is supposed to update.
	 */
	SPDK_CU_ASSERT_FATAL(req != NULL);
	CU_ASSERT(req->cb_fn == cb_fn);
	CU_ASSERT(req->cb_arg == cb_arg);
	CU_ASSERT(req->pid == getpid());
@@ -432,6 +433,7 @@ test_nvme_allocate_request(void)
				    cb_fn, cb_arg);

	/* all the req elements should now match the passed in paramters */
	SPDK_CU_ASSERT_FATAL(req != NULL);
	CU_ASSERT(req->cb_fn == cb_fn);
	CU_ASSERT(req->cb_arg == cb_arg);
	CU_ASSERT(memcmp(&req->payload, &payload, payload_struct_size) == 0);
@@ -490,6 +492,7 @@ test_nvme_allocate_request_user_copy(void)

	req = nvme_allocate_request_user_copy(&qpair, buffer, payload_size, cb_fn,
					      cb_arg, host_to_controller);
	SPDK_CU_ASSERT_FATAL(req != NULL);
	CU_ASSERT(req->user_cb_fn == cb_fn);
	CU_ASSERT(req->user_cb_arg == cb_arg);
	CU_ASSERT(req->user_buffer == buffer);
@@ -503,6 +506,7 @@ test_nvme_allocate_request_user_copy(void)

	req = nvme_allocate_request_user_copy(&qpair, buffer, payload_size, cb_fn,
					      cb_arg, host_to_controller);
	SPDK_CU_ASSERT_FATAL(req != NULL);
	CU_ASSERT(req->user_cb_fn == cb_fn);
	CU_ASSERT(req->user_cb_arg == cb_arg);
	CU_ASSERT(req->user_buffer == buffer);