dm: gvt: add bound check in gvt_init_config()

gvt_init_config() may perform out-of-range read on host_config, add
bound check before accessing it.

Tracked-On: #8382
Signed-off-by: Jiaqing Zhao <jiaqing.zhao@linux.intel.com>
Reviewed-by: Jian Jun Chen <jian.jun.chen@intel.com>
This commit is contained in:
Jiaqing Zhao 2023-04-21 11:07:54 +00:00 committed by acrnsi-robot
parent 0016a64655
commit 56446fe366
1 changed files with 1 additions and 1 deletions

View File

@ -256,7 +256,7 @@ gvt_init_config(struct pci_gvt *gvt)
/* capability */
pci_set_cfgdata8(gvt->gvt_pi, PCIR_CAP_PTR, gvt->host_config[0x34]);
cap_ptr = gvt->host_config[0x34];
while (cap_ptr != 0) {
while (cap_ptr != 0 && cap_ptr <= PCI_REGMAX - 15) {
pci_set_cfgdata32(gvt->gvt_pi, cap_ptr,
gvt->host_config[cap_ptr]);
pci_set_cfgdata32(gvt->gvt_pi, cap_ptr + 4,