]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commit - drivers/net/ethernet/mellanox/mlx5/core/en_main.c
bpf, mlx5: fix various refcount issues in mlx5e_xdp_set
authorDaniel Borkmann <daniel@iogearbox.net>
Sat, 19 Nov 2016 00:45:01 +0000 (01:45 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 21 Nov 2016 16:25:58 +0000 (11:25 -0500)
commitc54c06290428554bc0e26d58f21a7865cbe995af
tree9e7d91610dc3433f34904537ffefaae7675d0f8a
parent97bc402db7821259f6a722cb38e060aa9b35b6e8
bpf, mlx5: fix various refcount issues in mlx5e_xdp_set

There are multiple issues in mlx5e_xdp_set():

1) The batched bpf_prog_add() is currently not checked for errors. When
   doing so, it should be done at an earlier point in time to makes sure
   that we cannot fail anymore at the time we want to set the program for
   each channel. The batched refs short-cut can only be performed when we
   don't need to perform a reset for changing the rq type and the device
   was in opened state. In case the device was not in opened state, then
   the next mlx5e_open_locked() will aquire the refs from the control prog
   via mlx5e_create_rq(), same when we need to perform a reset.

2) When swapping the priv->xdp_prog, then no extra reference count must be
   taken since we got that from call path via dev_change_xdp_fd() already.
   Otherwise, we'd never be able to release the program. Also, bpf_prog_add()
   without checking the return code could fail.

Fixes: 86994156c736 ("net/mlx5e: XDP fast RX drop bpf programs support")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Saeed Mahameed <saeedm@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mellanox/mlx5/core/en_main.c