Skip to content

Commit

Permalink
net: ipconfig: Fix more use after free
Browse files Browse the repository at this point in the history
While commit 9c706a4 ("net: ipconfig: fix use after free") avoids
the use after free, the resulting code still ends up calling both the
ic_setup_if() and ic_setup_routes() after calling ic_close_devs(), and
access to the device is still required.

Move the call to ic_close_devs() to the very end of the function.

Signed-off-by: Thierry Reding <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
thierryreding authored and davem330 committed Aug 17, 2016
1 parent 00062a9 commit d2d371a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions net/ipv4/ipconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -1530,12 +1530,14 @@ static int __init ip_auto_config(void)
* 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;
err = -1;
else
err = 0;

ic_close_devs();

return 0;
return err;
}

late_initcall(ip_auto_config);
Expand Down

0 comments on commit d2d371a

Please sign in to comment.