Skip to content

Commit d2d371a

Browse files
thierryredingdavem330
authored andcommitted
net: ipconfig: Fix more use after free
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]>
1 parent 00062a9 commit d2d371a

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

net/ipv4/ipconfig.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1530,12 +1530,14 @@ static int __init ip_auto_config(void)
15301530
* Close all network devices except the device we've
15311531
* autoconfigured and set up routes.
15321532
*/
1533-
ic_close_devs();
15341533
if (ic_setup_if() < 0 || ic_setup_routes() < 0)
1535-
return -1;
1534+
err = -1;
1535+
else
1536+
err = 0;
15361537

1538+
ic_close_devs();
15371539

1538-
return 0;
1540+
return err;
15391541
}
15401542

15411543
late_initcall(ip_auto_config);

0 commit comments

Comments
 (0)