x86/hvm: Fix memory leaks in hvm_copy_context_and_params()
PATCH 1/1 x86/hvm: Fix memory leaks in hvm_copy_context_and_params()
Any error from hvm_save() or hvm_set_param() leaks the c.data allocation.
Spotted by Coverity.
Fixes 353744830 "x86/hvm: introduce hvm_copy_context_and_params"
Signed-off-by Andrew Cooper <[email protected]>
---
CC: Jan Beulich <[email protected]>
CC: Wei Liu <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Tamas K Lengyel <[email protected]>
This was the XenServer internal Coverity. The public one doesn't appear to have spotted the issue, so no Coverity-ID tag for the fix.
--- xen/arch/x86/hvm/hvm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
xen/arch/x86/hvm/hvm.c +4 -2
@@ -5318,7 +5318,7 @@ int hvm_copy_context_and_params(struct domain *dst, struct domain *src)return -ENOMEM ;if ( (rc =hvm_save (src, &c)) ) -return rc; + goto out;for ( i =0 ; i <HVM_NR_PARAMS ; i++ ) {
@@ -5328,11 +5328,13 @@ int hvm_copy_context_and_params(struct domain *dst, struct domain *src)continue ;if ( (rc =hvm_set_param (dst, i, value)) ) -return rc; + goto out; } c.cur =0 ; rc =hvm_load (dst, &c); + + out:vfree (c.data);return rc;
Signature · 1 line
2.11.0
Quoted 6 lines · Andrew Cooper
Any error from
hvm_save()orhvm_set_param()leaks the c.data allocation.Spotted by Coverity.
Fixes 353744830 "x86/hvm: introduce hvm_copy_context_and_params"Signed-off-by Andrew Cooper <[email protected]>
Reviewed-by Jan Beulich <[email protected]>
Quoted 7 lines · Andrew Cooper
Any error from
hvm_save()orhvm_set_param()leaks the c.data allocation.Spotted by Coverity.
Fixes 353744830 "x86/hvm: introduce hvm_copy_context_and_params"Signed-off-by Andrew Cooper <[email protected]>
Thanks for the fix, my bad!
Tamas