summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2016-02-24 21:37:42 +0100
committerLennart Poettering <lennart@poettering.net>2016-04-12 13:43:30 +0200
commit21b3926840b22c738a5e575f089485732e1cbd28 (patch)
treeaaacf2cd2937bf1aa58b62f0d9cbdbc9e0a7db04 /src
parent2c289ea8332a2c0777d8940058ff7a6293f59b6c (diff)
network: hashmap_put() can fail
Let's properly handle hashmap_put() failing.
Diffstat (limited to 'src')
-rw-r--r--src/network/networkd-route.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/network/networkd-route.c b/src/network/networkd-route.c
index e065a5a5a9..ab9b777d9a 100644
--- a/src/network/networkd-route.c
+++ b/src/network/networkd-route.c
@@ -52,8 +52,7 @@ int route_new_static(Network *network, unsigned section, Route **ret) {
int r;
if (section) {
- route = hashmap_get(network->routes_by_section,
- UINT_TO_PTR(section));
+ route = hashmap_get(network->routes_by_section, UINT_TO_PTR(section));
if (route) {
*ret = route;
route = NULL;
@@ -67,16 +66,18 @@ int route_new_static(Network *network, unsigned section, Route **ret) {
return r;
route->protocol = RTPROT_STATIC;
- route->network = network;
-
- LIST_PREPEND(routes, network->static_routes, route);
if (section) {
+ r = hashmap_put(network->routes_by_section, UINT_TO_PTR(route->section), route);
+ if (r < 0)
+ return r;
+
route->section = section;
- hashmap_put(network->routes_by_section,
- UINT_TO_PTR(route->section), route);
}
+ LIST_PREPEND(routes, network->static_routes, route);
+ route->network = network;
+
*ret = route;
route = NULL;