diff options
author | Jason Gunthorpe <jgg@mellanox.com> | 2019-01-08 23:27:06 +0000 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-01-26 09:44:25 +0100 |
commit | 8c871bdbd02f71e31961dce3a70e77d450765f16 (patch) | |
tree | 7c417f8e0fe00cf4ad87a108db67a5da8bdfe3b7 /net | |
parent | 4d97ac0053d163657086eb81b9f6023059a3966d (diff) | |
download | linux-stable-8c871bdbd02f71e31961dce3a70e77d450765f16.tar.gz linux-stable-8c871bdbd02f71e31961dce3a70e77d450765f16.tar.bz2 linux-stable-8c871bdbd02f71e31961dce3a70e77d450765f16.zip |
packet: Do not leak dev refcounts on error exit
[ Upstream commit d972f3dce8d161e2142da0ab1ef25df00e2f21a9 ]
'dev' is non NULL when the addr_len check triggers so it must goto a label
that does the dev_put otherwise dev will have a leaked refcount.
This bug causes the ib_ipoib module to become unloadable when using
systemd-network as it triggers this check on InfiniBand links.
Fixes: 99137b7888f4 ("packet: validate address length")
Reported-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Acked-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net')
-rw-r--r-- | net/packet/af_packet.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 65cfce2e5010..5f05f51ec4a5 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c @@ -2276,7 +2276,7 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg) addr = saddr->sll_halen ? saddr->sll_addr : NULL; dev = dev_get_by_index(sock_net(&po->sk), saddr->sll_ifindex); if (addr && dev && saddr->sll_halen < dev->addr_len) - goto out; + goto out_put; } err = -ENXIO; @@ -2439,7 +2439,7 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len) addr = saddr->sll_halen ? saddr->sll_addr : NULL; dev = dev_get_by_index(sock_net(sk), saddr->sll_ifindex); if (addr && dev && saddr->sll_halen < dev->addr_len) - goto out; + goto out_unlock; } err = -ENXIO; |