net: ethernet: mtk_eth_soc: fix flow block refcounting logic

Since we call flow_block_cb_decref on FLOW_BLOCK_UNBIND, we also need to
call flow_block_cb_incref for a newly allocated cb.
Also fix the accidentally inverted refcount check on unbind.

Fixes: 502e84e238 ("net: ethernet: mtk_eth_soc: add flow offloading support")
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>
Link: https://lore.kernel.org/r/20230330120840.52079-1-nbd@nbd.name
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Felix Fietkau 2023-03-30 14:08:38 +02:00 committed by Jakub Kicinski
parent 2960a2d33b
commit 8c1cb87c2a

View File

@ -576,6 +576,7 @@ mtk_eth_setup_tc_block(struct net_device *dev, struct flow_block_offload *f)
if (IS_ERR(block_cb)) if (IS_ERR(block_cb))
return PTR_ERR(block_cb); return PTR_ERR(block_cb);
flow_block_cb_incref(block_cb);
flow_block_cb_add(block_cb, f); flow_block_cb_add(block_cb, f);
list_add_tail(&block_cb->driver_list, &block_cb_list); list_add_tail(&block_cb->driver_list, &block_cb_list);
return 0; return 0;
@ -584,7 +585,7 @@ mtk_eth_setup_tc_block(struct net_device *dev, struct flow_block_offload *f)
if (!block_cb) if (!block_cb)
return -ENOENT; return -ENOENT;
if (flow_block_cb_decref(block_cb)) { if (!flow_block_cb_decref(block_cb)) {
flow_block_cb_remove(block_cb, f); flow_block_cb_remove(block_cb, f);
list_del(&block_cb->driver_list); list_del(&block_cb->driver_list);
} }