Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/sgx: Ensure enclave data available during debug print

In support of debugging the SGX tests print details from
the enclave and its memory mappings if any failure is encountered
during enclave loading.

When a failure is encountered no data is printed because the
printing of the data is preceded by cleanup of the data.

Move the data cleanup after the data print.

Fixes: 147172148909 ("selftests/sgx: Dump segments and /proc/self/maps only on failure")
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Acked-by: Shuah Khan <skhan@linuxfoundation.org>
Link: https://lkml.kernel.org/r/dab672f771e9b99e50c17ae2a75dc0b020cb0ce9.1644355600.git.reinette.chatre@intel.com

authored by

Reinette Chatre and committed by
Dave Hansen
2db703fc fff36bcb

+2 -2
+2 -2
tools/testing/selftests/sgx/main.c
··· 186 186 return true; 187 187 188 188 err: 189 - encl_delete(encl); 190 - 191 189 for (i = 0; i < encl->nr_segments; i++) { 192 190 seg = &encl->segment_tbl[i]; 193 191 ··· 205 207 } 206 208 207 209 TH_LOG("Failed to initialize the test enclave.\n"); 210 + 211 + encl_delete(encl); 208 212 209 213 return false; 210 214 }