diff mbox series

[3/3] trace-cmd: Do not return zero length name for guest by name

Message ID 20220922002348.3302169-4-rostedt@goodmis.org (mailing list archive)
State Accepted
Commit 54931be836aad82a7d6abea78604a5578072ab89
Headers show
Series trace-cmd: A few fixes | expand

Commit Message

Steven Rostedt Sept. 22, 2022, 12:23 a.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

The function trace_get_guest() will first look for a guest by name, and
if it finds one, it will return it. But if the guest added did not have
a name (but had an empty string), it would return any guest that also
did not have a name (but just an empty string). If two guests did not
have a name, and the CID was used, then the first guest would be
returned for the second guest, breaking the creating of two guests where
both were without names.

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 tracecmd/trace-vm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/tracecmd/trace-vm.c b/tracecmd/trace-vm.c
index 09bd60259258..f78f1d83386b 100644
--- a/tracecmd/trace-vm.c
+++ b/tracecmd/trace-vm.c
@@ -35,7 +35,7 @@  static struct trace_guest *get_guest_by_name(const char *name)
 {
 	int i;
 
-	if (!guests)
+	if (!guests || !strlen(name))
 		return NULL;
 
 	for (i = 0; i < guests_len; i++)