bpf, mlx5: fix mlx5e_create_rq taking reference on prog
authorDaniel Borkmann <daniel@iogearbox.net>
Sat, 19 Nov 2016 00:45:00 +0000 (01:45 +0100)
committerDavid S. Miller <davem@davemloft.net>
Mon, 21 Nov 2016 16:25:57 +0000 (11:25 -0500)
commit97bc402db7821259f6a722cb38e060aa9b35b6e8
tree47fd432ccb666cf167358f005b47d1e2abe5e6bf
parentf81a8a02bb3b3e882ba6aa580230c13b5be64849
bpf, mlx5: fix mlx5e_create_rq taking reference on prog

In mlx5e_create_rq(), when creating a new queue, we call bpf_prog_add() but
without checking the return value. bpf_prog_add() can fail since 92117d8443bc
("bpf: fix refcnt overflow"), so we really must check it. Take the reference
right when we assign it to the rq from priv->xdp_prog, and just drop the
reference on error path. Destruction in mlx5e_destroy_rq() looks good, though.

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
kernel/bpf/syscall.c