[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] x86/vpci: validate data first in register_vpci_mmcfg_handler
commit 0e8e4a4437402bb53aa41081912ef14021ebb6ea Author: Wei Liu <wei.liu2@xxxxxxxxxx> AuthorDate: Tue Mar 27 12:04:20 2018 +0100 Commit: Wei Liu <wei.liu2@xxxxxxxxxx> CommitDate: Tue Mar 27 16:29:46 2018 +0100 x86/vpci: validate data first in register_vpci_mmcfg_handler Avoid the need to deallocate memory when the data is invalid. It has the benefit to not fragment memory in Xen. Signed-off-by: Wei Liu <wei.liu2@xxxxxxxxxx> Reviewed-by: Roger Pau Monné <roger.pau@xxxxxxxxxx> Acked-by: Jan Beulich <jbeulich@xxxxxxxx> --- xen/arch/x86/hvm/io.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/xen/arch/x86/hvm/io.c b/xen/arch/x86/hvm/io.c index 556810c126..9af5e3fee6 100644 --- a/xen/arch/x86/hvm/io.c +++ b/xen/arch/x86/hvm/io.c @@ -511,18 +511,16 @@ int register_vpci_mmcfg_handler(struct domain *d, paddr_t addr, unsigned int start_bus, unsigned int end_bus, unsigned int seg) { - struct hvm_mmcfg *mmcfg, *new = xmalloc(struct hvm_mmcfg); + struct hvm_mmcfg *mmcfg, *new; ASSERT(is_hardware_domain(d)); - if ( !new ) - return -ENOMEM; - if ( start_bus > end_bus ) - { - xfree(new); return -EINVAL; - } + + new = xmalloc(struct hvm_mmcfg); + if ( !new ) + return -ENOMEM; new->addr = addr + (start_bus << 20); new->start_bus = start_bus; -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |