All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1] xen/domain: fix memory leak in domain_create()
@ 2025-06-23  1:16 dmkhn
  2025-06-23  8:09 ` Jan Beulich
  0 siblings, 1 reply; 3+ messages in thread
From: dmkhn @ 2025-06-23  1:16 UTC (permalink / raw)
  To: xen-devel
  Cc: andrew.cooper3, anthony.perard, jbeulich, julien, michal.orzel,
	roger.pau, sstabellini, dmukhin

From: Denis Mukhin <dmukhin@ford.com>

Fix potential memory leak in domain_create() in late hardware domain case.

Fixes: b959f3b820f5 ("xen: introduce hardware domain create flag")
Signed-off-by: Denis Mukhin <dmukhin@ford.com>
---
I think that no memory allocation is required before performing late hwdom
checks (ID range and hwdom existance).

Looks like sanitise_domain_config() could better fit for performing such
configuration checks.

Alternatively, hardware_domid range could be checked via custom parser
instead of code in domain_create() and then hwdom existance can be moved
before alloc_domain_struct().

Thoughts?
---
 xen/common/domain.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/xen/common/domain.c b/xen/common/domain.c
index 2f6b0af50dd3..5ad1ac872798 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -825,7 +825,10 @@ struct domain *domain_create(domid_t domid,
 
         /* late_hwdom is only allowed for dom0. */
         if ( hardware_domain && hardware_domain->domain_id )
+        {
+            free_domain_struct(d);
             return ERR_PTR(-EINVAL);
+        }
 
         old_hwdom = hardware_domain;
         hardware_domain = d;
-- 
2.34.1




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

end of thread, other threads:[~2025-06-24  4:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-23  1:16 [PATCH v1] xen/domain: fix memory leak in domain_create() dmkhn
2025-06-23  8:09 ` Jan Beulich
2025-06-24  4:19   ` dmkhn

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.