Skip to content

Commit 042c393

Browse files
lifeixlijinxia
authored andcommitted
hv: trusty: fix get_max_svn_index return type inconsistent
Function return type should consistent. Tracked-On: #861 Signed-off-by: Li, Fei1 <fei1.li@intel.com>
1 parent c200c98 commit 042c393

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

hypervisor/arch/x86/trusty.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -334,15 +334,10 @@ void switch_world(struct acrn_vcpu *vcpu, int next_world)
334334
arch->cur_context = next_world;
335335
}
336336

337-
static int32_t get_max_svn_index(void)
337+
static inline uint32_t get_max_svn_index(void)
338338
{
339339
uint32_t i, max_svn_idx = 0U;
340340

341-
if ((g_key_info.num_seeds == 0U) ||
342-
(g_key_info.num_seeds > BOOTLOADER_SEED_MAX_ENTRIES)) {
343-
return -1;
344-
}
345-
346341
for (i = 1U; i < g_key_info.num_seeds; i++) {
347342
if (g_key_info.dseed_list[i].cse_svn >
348343
g_key_info.dseed_list[i-1].cse_svn) {
@@ -358,17 +353,14 @@ static bool derive_aek(uint8_t *attkb_key)
358353
const int8_t salt[] = "Attestation Keybox Encryption Key";
359354
const uint8_t *ikm;
360355
uint32_t ikm_len;
361-
int32_t max_svn_idx;
356+
uint32_t max_svn_idx;
362357

363-
if (!attkb_key) {
358+
if ((!attkb_key) || (g_key_info.num_seeds == 0U) ||
359+
(g_key_info.num_seeds > BOOTLOADER_SEED_MAX_ENTRIES)) {
364360
return false;
365361
}
366362

367363
max_svn_idx = get_max_svn_index();
368-
if (max_svn_idx < 0) {
369-
return false;
370-
}
371-
372364
ikm = g_key_info.dseed_list[max_svn_idx].seed;
373365
/* only the low 32 bits of seed are valid */
374366
ikm_len = 32;

0 commit comments

Comments
 (0)