]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: set return value at the end of the function
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 3 Feb 2021 15:44:03 +0000 (00:44 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 12 Feb 2021 13:43:10 +0000 (22:43 +0900)
The later netlink_call_async() call may fail. We should not touch the
return value when the function failed.

src/network/networkd-route.c

index 5a908dbeb0f1c20b8b5b28af24fcb404e928fcc4..e46184535183996f41a6fc6767c33b5255f8e10e 100644 (file)
@@ -1077,6 +1077,7 @@ int route_configure(
 
         _cleanup_(sd_netlink_message_unrefp) sd_netlink_message *req = NULL;
         int r, k = 0;
+        Route *nr;
 
         assert(link);
         assert(link->manager);
@@ -1164,14 +1165,9 @@ int route_configure(
                 return log_link_error_errno(link, r, "Could not append RTA_MULTIPATH attribute: %m");
 
         if (ordered_set_isempty(route->multipath_routes)) {
-                Route *nr;
-
                 k = route_add_and_setup_timer(link, route, NULL, &nr);
                 if (k < 0)
                         return k;
-
-                if (ret)
-                        *ret = nr;
         } else {
                 MultipathRoute *m;
 
@@ -1193,6 +1189,9 @@ int route_configure(
 
         link_ref(link);
 
+        if (ret)
+                *ret = nr;
+
         return k;
 }