PATCH [3/5]: mkinitrd: fix multiple memleaks in network handling code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi all,

This patch fixes multiple memleaks in the network handling code.

Regards,

Hans
diff -up mkinitrd-6.0.75/nash/network.c.leak mkinitrd-6.0.75/nash/network.c
--- mkinitrd-6.0.75/nash/network.c.leak	2009-01-31 13:06:38.000000000 +0100
+++ mkinitrd-6.0.75/nash/network.c	2009-01-31 13:13:01.000000000 +0100
@@ -149,6 +149,7 @@ static int nashSetMTU(char * dev, int mt
     struct nl_cache *cache = NULL;
     struct rtnl_link *link = NULL;
     struct rtnl_link *request = NULL;
+    int ret;
 
     if (dev == NULL || mtu <= 0)
         return 1;
@@ -168,6 +169,7 @@ static int nashSetMTU(char * dev, int mt
     }
 
     if ((link = rtnl_link_get_by_name(cache, dev)) == NULL) {
+        nl_cache_free(cache);
         nl_close(handle);
         nl_handle_destroy(handle);
         return 1;
@@ -176,14 +178,15 @@ static int nashSetMTU(char * dev, int mt
     request = rtnl_link_alloc();
     rtnl_link_set_mtu(request, mtu);
 
-    if (rtnl_link_change(handle, link, request, 0)) {
-        rtnl_link_put(link);
-        nl_close(handle);
-        nl_handle_destroy(handle);
-        return 1;
-    }
+    ret = rtnl_link_change(handle, link, request, 0);
 
-    return 0;
+    rtnl_link_put(link);
+    rtnl_link_put(request);
+    nl_cache_free(cache);
+    nl_close(handle);
+    nl_handle_destroy(handle);
+
+    return ret;
 }
 
 static char *dhclientLeaseLineParse(char *linebuf, char *key) {
@@ -322,6 +325,7 @@ static char *nashSetupInterface(char *de
     }
 
     /* success */
+    nl_cache_free(cache);
     nl_close(handle);
     nl_handle_destroy(handle);
     return NULL;
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list

[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux