discover/network: free buffers from resolv.conf update
authorJeremy Kerr <jk@ozlabs.org>
Thu, 15 Aug 2013 07:27:39 +0000 (15:27 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Fri, 16 Aug 2013 04:43:39 +0000 (12:43 +0800)
Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
discover/network.c

index 8be07aa9bb7285984c03d53dbaa7647bf76ac2a0..4b9e4f10958f733df1f661c8e8f5b087d4f8a16a 100644 (file)
@@ -441,17 +441,18 @@ static void network_init_dns(struct network *network)
                memcpy(buf + len, dns_conf, dns_conf_len);
                len += dns_conf_len;
                modified = true;
-       }
 
-       if (!modified)
-               return;
+               talloc_free(dns_conf);
+       }
 
-       rc = replace_file("/etc/resolv.conf", buf, len);
-       if (rc) {
-               pb_log("error replacing resolv.conf: %s\n", strerror(errno));
-               return;
+       if (modified) {
+               rc = replace_file("/etc/resolv.conf", buf, len);
+               if (rc)
+                       pb_log("error replacing resolv.conf: %s\n",
+                                       strerror(errno));
        }
 
+       talloc_free(buf);
 }
 
 struct network *network_init(void *ctx, struct waitset *waitset, bool dry_run)