All of lore.kernel.org
 help / color / mirror / Atom feed
* libxc: memory leak in handle_hvm_context
@ 2019-05-17 11:49 ` Viktor Mitin
  0 siblings, 0 replies; 6+ messages in thread
From: Viktor Mitin @ 2019-05-17 11:49 UTC (permalink / raw)
  To: Andrew Cooper, Ian Campbell, xen-devel; +Cc: Volodymyr Babchuk

Hi All,

It seems there is a memory leak in libxc function handle_hvm_context
(in file tools/libxc/xc_sr_restore_x86_hvm.c.). There is a malloc of
variable p without free.
Please take a look.

+/*
+ * Process an HVM_CONTEXT record from the stream.
+ */
+static int handle_hvm_context(struct xc_sr_context *ctx,
+                              struct xc_sr_record *rec)
+{
+    xc_interface *xch = ctx->xch;
+    void *p;
+
+    p = malloc(rec->length);
+    if ( !p )
+    {
+        ERROR("Unable to allocate %u bytes for hvm context", rec->length);
+        return -1;
+    }
+
+    free(ctx->x86_hvm.restore.context);
+
+    ctx->x86_hvm.restore.context = memcpy(p, rec->data, rec->length);
+    ctx->x86_hvm.restore.contextsz = rec->length;
+
+    return 0;
+}

Thanks

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-05-17 12:24 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-05-17 11:49 libxc: memory leak in handle_hvm_context Viktor Mitin
2019-05-17 11:49 ` [Xen-devel] " Viktor Mitin
2019-05-17 11:56 ` Viktor Mitin
2019-05-17 11:56   ` [Xen-devel] " Viktor Mitin
2019-05-17 12:23   ` Andrew Cooper
2019-05-17 12:23     ` [Xen-devel] " Andrew Cooper

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.