From 78b41a2319c3c247a0223187edaea4c9ba98e83b Mon Sep 17 00:00:00 2001 From: Michael Tremer Date: Sun, 4 Jun 2023 16:52:59 +0000 Subject: [PATCH] daemon: Fix return code handling when listing ports/zones Signed-off-by: Michael Tremer --- src/networkd/daemon-bus.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/networkd/daemon-bus.c b/src/networkd/daemon-bus.c index 4de8c0fb..f5f7abd0 100644 --- a/src/networkd/daemon-bus.c +++ b/src/networkd/daemon-bus.c @@ -49,9 +49,17 @@ static int __nw_daemon_bus_list_ports(nw_daemon* daemon, nw_port* port, void* da // Fetch bus path char* path = nw_port_bus_path(port); + // Append the port to the message r = sd_bus_message_append(reply, "(so)", name, path); + if (r < 0) + goto ERROR; - free(path); + // Success + r = 0; + +ERROR: + if (path) + free(path); return r; } @@ -98,9 +106,17 @@ static int __nw_daemon_bus_list_zones(nw_daemon* daemon, nw_zone* zone, void* da // Fetch bus path char* path = nw_zone_bus_path(zone); + // Append the zone to the message r = sd_bus_message_append(reply, "(so)", name, path); + if (r < 0) + goto ERROR; - free(path); + // Success + r = 0; + +ERROR: + if (path) + free(path); return r; } -- 2.39.2