]> git.baikalelectronics.ru Git - kernel.git/commit
hsr: fix refcnt leak of hsr slave interface
authorTaehee Yoo <ap420073@gmail.com>
Thu, 5 Mar 2020 00:02:54 +0000 (00:02 +0000)
committerDavid S. Miller <davem@davemloft.net>
Thu, 5 Mar 2020 19:59:47 +0000 (11:59 -0800)
commiteb93a25800a58a56cbef7a2659068d090bf52661
treef5d5eb1a59dab6890d0f247b99348e1fd577a877
parentd59c75c28eb1db97418b69fcce1370a68678271a
hsr: fix refcnt leak of hsr slave interface

In the commit 84ba9354fb6e ("hsr: use upper/lower device infrastructure"),
dev_get() was removed but dev_put() in the error path wasn't removed.
So, if creating hsr interface command is failed, the reference counter leak
of lower interface would occur.

Test commands:
    ip link add dummy0 type dummy
    ip link add ipvlan0 link dummy0 type ipvlan mode l2
    ip link add ipvlan1 link dummy0 type ipvlan mode l2
    ip link add hsr0 type hsr slave1 ipvlan0 slave2 ipvlan1
    ip link del ipvlan0

Result:
[  633.271992][ T1280] unregister_netdevice: waiting for ipvlan0 to become free. Usage count = -1

Fixes: 84ba9354fb6e ("hsr: use upper/lower device infrastructure")
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/hsr/hsr_slave.c