packet: missing dev_put() in packet_do_bind()
authorLars Westerhoff <lars.westerhoff@newtec.eu>
Mon, 27 Jul 2015 22:32:21 +0000 (01:32 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 27 Jul 2015 22:38:58 +0000 (15:38 -0700)
commit158cd4af8dedbda0d612d448c724c715d0dda649
tree6bccf1b8da44cf06707413aed948e81032987c81
parentc5c62f1bb0e1fc94ab77ec01e92ccab5cb249742
packet: missing dev_put() in packet_do_bind()

When binding a PF_PACKET socket, the use count of the bound interface is
always increased with dev_hold in dev_get_by_{index,name}.  However,
when rebound with the same protocol and device as in the previous bind
the use count of the interface was not decreased.  Ultimately, this
caused the deletion of the interface to fail with the following message:

unregister_netdevice: waiting for dummy0 to become free. Usage count = 1

This patch moves the dev_put out of the conditional part that was only
executed when either the protocol or device changed on a bind.

Fixes: 902fefb82ef7 ('packet: improve socket create/bind latency in some cases')
Signed-off-by: Lars Westerhoff <lars.westerhoff@newtec.eu>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/packet/af_packet.c