• Daniel Lezcano's avatar
    netns: fix double free at netns creation · 486a87f1
    Daniel Lezcano authored
    This patch fix a double free when a network namespace fails.
    The previous code does a kfree of the net_generic structure when
    one of the init subsystem initialization fails.
    The 'setup_net' function does kfree(ng) and returns an error.
    The caller, 'copy_net_ns', call net_free on error, and this one
    calls kfree(net->gen), making this pointer freed twice.
    
    This patch make the code symetric, the net_alloc does the net_generic
    allocation and the net_free frees the net_generic.
    Signed-off-by: default avatarDaniel Lezcano <daniel.lezcano@free.fr>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    486a87f1
net_namespace.c 11.5 KB