* [PATCH] tools/xenstore: fix error handling of check_store()
@ 2022-01-21 13:12 Juergen Gross
2022-01-21 15:22 ` Anthony PERARD
0 siblings, 1 reply; 2+ messages in thread
From: Juergen Gross @ 2022-01-21 13:12 UTC (permalink / raw)
To: xen-devel; +Cc: Juergen Gross, Wei Liu, Julien Grall, Anthony PERARD
check_store() has an incomplete error handling: it doesn't check
whether "root" allocation succeeded, and it is leaking the memory of
"root" in case create_hashtable() fails.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
tools/xenstore/xenstored_core.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/tools/xenstore/xenstored_core.c b/tools/xenstore/xenstored_core.c
index c386ae6129..91d3adccb1 100644
--- a/tools/xenstore/xenstored_core.c
+++ b/tools/xenstore/xenstored_core.c
@@ -2050,14 +2050,18 @@ static void clean_store(struct hashtable *reachable)
void check_store(void)
{
- char * root = talloc_strdup(NULL, "/");
- struct hashtable * reachable =
- create_hashtable(16, hash_from_key_fn, keys_equal_fn);
-
- if (!reachable) {
+ char *root = talloc_strdup(NULL, "/");
+ struct hashtable *reachable;
+
+ if (!root) {
log("check_store: ENOMEM");
return;
}
+ reachable = create_hashtable(16, hash_from_key_fn, keys_equal_fn);
+ if (!reachable) {
+ log("check_store: ENOMEM");
+ goto out_root;
+ }
log("Checking store ...");
if (!check_store_(root, reachable) &&
@@ -2067,6 +2071,7 @@ void check_store(void)
hashtable_destroy(reachable, 0 /* Don't free values (they are all
(void *)1) */);
+ out_root:
talloc_free(root);
}
--
2.31.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] tools/xenstore: fix error handling of check_store()
2022-01-21 13:12 [PATCH] tools/xenstore: fix error handling of check_store() Juergen Gross
@ 2022-01-21 15:22 ` Anthony PERARD
0 siblings, 0 replies; 2+ messages in thread
From: Anthony PERARD @ 2022-01-21 15:22 UTC (permalink / raw)
To: Juergen Gross; +Cc: xen-devel, Wei Liu, Julien Grall
On Fri, Jan 21, 2022 at 02:12:19PM +0100, Juergen Gross wrote:
> check_store() has an incomplete error handling: it doesn't check
> whether "root" allocation succeeded, and it is leaking the memory of
> "root" in case create_hashtable() fails.
>
> Signed-off-by: Juergen Gross <jgross@suse.com>
Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
Thanks,
--
Anthony PERARD
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-21 15:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-21 13:12 [PATCH] tools/xenstore: fix error handling of check_store() Juergen Gross
2022-01-21 15:22 ` Anthony PERARD
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.