]> git.baikalelectronics.ru Git - kernel.git/commit
bpf, mlx4: fix prog refcount in mlx4_en_try_alloc_resources error path
authorDaniel Borkmann <daniel@iogearbox.net>
Wed, 9 Nov 2016 21:02:34 +0000 (22:02 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sun, 13 Nov 2016 04:31:57 +0000 (23:31 -0500)
commit1512a6d04480634b6638906e3c24609a722e5fd4
treebbc81f35747fb25416c9015d23fc7071d54feb11
parent2427f770b8579ea480c0648d6245a04e26f8990f
bpf, mlx4: fix prog refcount in mlx4_en_try_alloc_resources error path

Commit 9fdc0c9037dc ("net/mlx4_en: Refactor the XDP forwarding rings
scheme") added a bug in that the prog's reference count is not dropped
in the error path when mlx4_en_try_alloc_resources() is failing from
mlx4_xdp_set().

We previously took bpf_prog_add(prog, priv->rx_ring_num - 1), that we
need to release again. Earlier in the call path, dev_change_xdp_fd()
itself holds a reference to the prog as well (hence the '- 1' in the
bpf_prog_add()), so a simple atomic_sub() is safe to use here. When
an error is propagated, then bpf_prog_put() is called eventually from
dev_change_xdp_fd()

Fixes: 9fdc0c9037dc ("net/mlx4_en: Refactor the XDP forwarding rings scheme")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx4/en_netdev.c
include/linux/bpf.h
kernel/bpf/syscall.c