Commit e71c185e authored by Jim Harris's avatar Jim Harris Committed by Tomasz Zawadzki
Browse files

test/nvme: use SPDK_CU_ASSERT_FATAL if nvme_pcie_poll_group_get_stats() fails



If it fails, tgroup_stat pointer does not get set, meaning the following
memcmp could cause a segfault.

This was found using LTO, even though the error message was somewhat confusing.
It reported there could be a source size of 0, not that one of the memcmp()
parameters could be NULL.

Signed-off-by: default avatarJim Harris <jim.harris@samsung.com>
Change-Id: I6e72e0932c0cc2f701d90fdbfaac17adb8eb771c
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/23307


Community-CI: Mellanox Build Bot
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarBen Walker <ben@nvidia.com>
Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
parent 197279c1
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -566,7 +566,7 @@ test_nvme_pcie_poll_group_get_stats(void)

	/* Get state success */
	rc = nvme_pcie_poll_group_get_stats(tgroup, &tgroup_stat);
	CU_ASSERT(rc == 0);
	SPDK_CU_ASSERT_FATAL(rc == 0);
	CU_ASSERT(tgroup_stat != NULL);
	CU_ASSERT(tgroup_stat->trtype == SPDK_NVME_TRANSPORT_PCIE);
	CU_ASSERT(memcmp(&tgroup_stat->pcie, &pgroup->stats, sizeof(struct spdk_nvme_pcie_stat)) == 0);