From 4e77dcfba1f1dc08f8025b555717fd137e19711f Mon Sep 17 00:00:00 2001 From: Yifan Liu Date: Wed, 11 Aug 2021 13:28:01 +0800 Subject: [PATCH] hv: Squash warning of code scanning tool The original use of recalc_checksum(eps->int_anchor, ...) may cause an array bound overflow warning from code scanning tool. This patch changes it to use offsetof to avoid using int_anchor directly. Tracked-On: #6383 Signed-off-by: Yifan Liu --- hypervisor/quirks/smbios.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hypervisor/quirks/smbios.c b/hypervisor/quirks/smbios.c index b8c2ec3c9..f6b7bbca7 100644 --- a/hypervisor/quirks/smbios.c +++ b/hypervisor/quirks/smbios.c @@ -190,7 +190,8 @@ static int copy_smbios_to_guest(struct acrn_vm *vm) struct smbios_entry_point *eps = &smbios_eps.eps; eps->st_addr = (uint32_t)gpa; /* the intermediate checksum covers the structure table field */ - recalc_checksum((uint8_t *)eps->int_anchor, 0xf, &eps->int_checksum); + recalc_checksum((uint8_t *)eps + offsetof(struct smbios_entry_point, int_anchor), + 0xf, &eps->int_checksum); } else { /* SMBIOS3 (_SM3_) */ struct smbios3_entry_point *eps3 = &smbios_eps.eps3;