* [PATCH] x86/hvm: Fix memory leaks in hvm_copy_context_and_params()
@ 2020-05-16 12:22 Andrew Cooper
2020-05-18 11:10 ` Jan Beulich
2020-05-18 17:23 ` Tamas K Lengyel
0 siblings, 2 replies; 3+ messages in thread
From: Andrew Cooper @ 2020-05-16 12:22 UTC (permalink / raw)
To: Xen-devel
Cc: Andrew Cooper, Tamas K Lengyel, Wei Liu, Jan Beulich,
Roger Pau Monné
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 <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Wei Liu <wl@xen.org>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Tamas K Lengyel <tamas@tklengyel.com>
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(-)
diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c
index 814b7020d8..0a3797ef6e 100644
--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -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;
--
2.11.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] x86/hvm: Fix memory leaks in hvm_copy_context_and_params()
2020-05-16 12:22 [PATCH] x86/hvm: Fix memory leaks in hvm_copy_context_and_params() Andrew Cooper
@ 2020-05-18 11:10 ` Jan Beulich
2020-05-18 17:23 ` Tamas K Lengyel
1 sibling, 0 replies; 3+ messages in thread
From: Jan Beulich @ 2020-05-18 11:10 UTC (permalink / raw)
To: Andrew Cooper; +Cc: Xen-devel, Tamas K Lengyel, Wei Liu, Roger Pau Monné
On 16.05.2020 14:22, Andrew Cooper wrote:
> 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 <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] x86/hvm: Fix memory leaks in hvm_copy_context_and_params()
2020-05-16 12:22 [PATCH] x86/hvm: Fix memory leaks in hvm_copy_context_and_params() Andrew Cooper
2020-05-18 11:10 ` Jan Beulich
@ 2020-05-18 17:23 ` Tamas K Lengyel
1 sibling, 0 replies; 3+ messages in thread
From: Tamas K Lengyel @ 2020-05-18 17:23 UTC (permalink / raw)
To: Andrew Cooper; +Cc: Xen-devel, Wei Liu, Jan Beulich, Roger Pau Monné
On Sat, May 16, 2020 at 6:22 AM Andrew Cooper <andrew.cooper3@citrix.com> wrote:
>
> 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 <andrew.cooper3@citrix.com>
Thanks for the fix, my bad!
Tamas
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-05-18 17:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-16 12:22 [PATCH] x86/hvm: Fix memory leaks in hvm_copy_context_and_params() Andrew Cooper
2020-05-18 11:10 ` Jan Beulich
2020-05-18 17:23 ` Tamas K Lengyel
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.