From 43b2327eb8851dcd7d8c9640f47d4985d98a8f62 Mon Sep 17 00:00:00 2001 From: Gao Junhao Date: Tue, 15 Oct 2019 01:31:24 +0000 Subject: [PATCH] dm: validation for input to public functions slot value should be checked in range before used to access bi->slotinfo[]. Tracked-On: #3822 Signed-off-by: Gao Junhao Reviewed-by: Yonghua Huang Acked-by: Yu Wang --- devicemodel/hw/pci/core.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/devicemodel/hw/pci/core.c b/devicemodel/hw/pci/core.c index 59c45f5df..21e274925 100644 --- a/devicemodel/hw/pci/core.c +++ b/devicemodel/hw/pci/core.c @@ -2490,6 +2490,8 @@ pci_get_vdev_info(int slot) bi = pci_businfo[0]; if (bi == NULL) return NULL; + if (slot < 0 || slot >= MAXSLOTS) + return NULL; si = &bi->slotinfo[slot]; if (si != NULL)