sd-ipv4ll: fix error path if sd-ipv4acd allocation fails
authorLennart Poettering <lennart@poettering.net>
Mon, 16 Nov 2015 23:16:21 +0000 (00:16 +0100)
committerLennart Poettering <lennart@poettering.net>
Mon, 16 Nov 2015 23:52:10 +0000 (00:52 +0100)
Let's make sure the destructor cannot hit the n_ref == 0 case.

src/libsystemd-network/sd-ipv4ll.c

index 006db6f..30a7ef5 100644 (file)
@@ -101,6 +101,8 @@ int sd_ipv4ll_new(sd_ipv4ll **ret) {
         if (!ll)
                 return -ENOMEM;
 
+        ll->n_ref = 1;
+
         r = sd_ipv4acd_new(&ll->acd);
         if (r < 0)
                 return r;
@@ -109,8 +111,6 @@ int sd_ipv4ll_new(sd_ipv4ll **ret) {
         if (r < 0)
                 return r;
 
-        ll->n_ref = 1;
-
         *ret = ll;
         ll = NULL;