]> git.ipfire.org Git - network.git/commitdiff
daemon: Fix return code handling when listing ports/zones
authorMichael Tremer <michael.tremer@ipfire.org>
Sun, 4 Jun 2023 16:52:59 +0000 (16:52 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 4 Jun 2023 16:52:59 +0000 (16:52 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/networkd/daemon-bus.c

index 4de8c0fb35a6c2455f9262bf50bccdaf76257561..f5f7abd029eb86b1cb2b5f59c7044ed9cb5d6005 100644 (file)
@@ -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;
 }