net: ipconfig: fix use after free
[cascardo/linux.git] / net / ipv4 / ipconfig.c
index 42cf629..66c2fe6 100644 (file)
@@ -1492,14 +1492,6 @@ static int __init ip_auto_config(void)
        if (ic_defaults() < 0)
                return -1;
 
-       /*
-        * Close all network devices except the device we've
-        * autoconfigured and set up routes.
-        */
-       ic_close_devs();
-       if (ic_setup_if() < 0 || ic_setup_routes() < 0)
-               return -1;
-
        /*
         * Record which protocol was actually used.
         */
@@ -1534,6 +1526,15 @@ static int __init ip_auto_config(void)
        pr_cont("\n");
 #endif /* !SILENT */
 
+       /*
+        * Close all network devices except the device we've
+        * autoconfigured and set up routes.
+        */
+       ic_close_devs();
+       if (ic_setup_if() < 0 || ic_setup_routes() < 0)
+               return -1;
+
+
        return 0;
 }