[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 06/16] x86/monitor: fix: set msr_bitmap to NULL after xfree
Fix: set d->arch.monitor.msr_bitmap to NULL after xfree, as the equivalence of it being NULL and xfreed is repeatedly presumed in the codebase. Along with this change, also properly reposition an 'if' targeting the aforementioned msr_bitmap when it is allocated and add likely/unlikely accordingly. Signed-off-by: Corneliu ZUZU <czuzu@xxxxxxxxxxxxxxx> --- xen/arch/x86/monitor.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/monitor.c b/xen/arch/x86/monitor.c index 29188e5..8f41f21 100644 --- a/xen/arch/x86/monitor.c +++ b/xen/arch/x86/monitor.c @@ -54,11 +54,12 @@ static inline void monitor_ctrlreg_disable_traps(struct domain *d) int monitor_init_domain(struct domain *d) { - if ( !d->arch.monitor.msr_bitmap ) + if ( likely(!d->arch.monitor.msr_bitmap) ) + { d->arch.monitor.msr_bitmap = xzalloc(struct monitor_msr_bitmap); - - if ( !d->arch.monitor.msr_bitmap ) - return -ENOMEM; + if ( unlikely(!d->arch.monitor.msr_bitmap) ) + return -ENOMEM; + } return 0; } @@ -66,6 +67,7 @@ int monitor_init_domain(struct domain *d) void monitor_cleanup_domain(struct domain *d) { xfree(d->arch.monitor.msr_bitmap); + d->arch.monitor.msr_bitmap = NULL; monitor_ctrlreg_disable_traps(d); -- 2.5.0 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |