]> git.baikalelectronics.ru Git - kernel.git/commit
net/caif: Fix dangling list pointer in freed object on error.
authorDavid S. Miller <davem@davemloft.net>
Tue, 8 Feb 2011 22:31:31 +0000 (14:31 -0800)
committerDavid S. Miller <davem@davemloft.net>
Tue, 8 Feb 2011 22:31:31 +0000 (14:31 -0800)
commita5856088d3dd8ef5a072767bd5296a8f6a919fca
tree472726c88dfd5a20c913bf557e4d6b5889e00510
parent7c8ffb36ebdefeb7e83efa8ac21b0332227d8b28
net/caif: Fix dangling list pointer in freed object on error.

rtnl_link_ops->setup(), and the "setup" callback passed to alloc_netdev*(),
cannot make state changes which need to be undone on failure.  There is
no cleanup mechanism available at this point.

So we have to add the caif private instance to the global list once we
are sure that register_netdev() has succedded in ->newlink().

Otherwise, if register_netdev() fails, the caller will invoke free_netdev()
and we will have a reference to freed up memory on the chnl_net_list.

Signed-off-by: David S. Miller <davem@davemloft.net>
net/caif/chnl_net.c