mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-07-30 23:16:40 +00:00
dm: validate the input in 'pci_emul_mem_handler()'
checking the inputs explicitly instead of using Assert. Tracked-On: #3991 Signed-off-by: Yonghua Huang <yonghua.huang@intel.com> Reviewed-by: Shuo Liu <shuo.a.liu@intel.com> Acked-by: Yu Wang <yu1.wang@intel.com>
This commit is contained in:
parent
21af6c84a4
commit
cf6ba23fd9
@ -417,11 +417,10 @@ pci_emul_mem_handler(struct vmctx *ctx, int vcpu, int dir, uint64_t addr,
|
||||
uint64_t offset;
|
||||
int bidx = (int) arg2;
|
||||
|
||||
assert(bidx <= PCI_BARMAX);
|
||||
assert(pdi->bar[bidx].type == PCIBAR_MEM32 ||
|
||||
pdi->bar[bidx].type == PCIBAR_MEM64);
|
||||
assert(addr >= pdi->bar[bidx].addr &&
|
||||
addr + size <= pdi->bar[bidx].addr + pdi->bar[bidx].size);
|
||||
if (addr + size > pdi->bar[bidx].addr + pdi->bar[bidx].size) {
|
||||
printf("%s, Out of emulated memory range.\n", __func__);
|
||||
return -ESRCH;
|
||||
}
|
||||
|
||||
offset = addr - pdi->bar[bidx].addr;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user