]> git.baikalelectronics.ru Git - kernel.git/commit
netns: fix double free at netns creation
authorDaniel Lezcano <daniel.lezcano@free.fr>
Sun, 22 Feb 2009 08:07:53 +0000 (00:07 -0800)
committerDavid S. Miller <davem@davemloft.net>
Sun, 22 Feb 2009 08:07:53 +0000 (00:07 -0800)
commit0f08b8e1289d6ab3fd61128948c4e1a7e61bcddd
treebdcb9749acfa351d0e53a9b0b243b0de3ce0d02c
parentf04c63487c1d111ee0fc76e4b82950cfe07dd14c
netns: fix double free at netns creation

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: Daniel Lezcano <daniel.lezcano@free.fr>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/net_namespace.c