Skip to content

Commit fd77697

Browse files
Michael Chankuba-moo
authored andcommitted
bnxt_en: Fix RCU locking for ntuple filters in bnxt_srxclsrldel()
After looking up an ntuple filter from a RCU hash list, the rcu_read_unlock() call should be made after reading the structure, or after determining that the filter cannot age out (by aRFS). The existing code was calling rcu_read_unlock() too early in bnxt_srxclsrldel(). As suggested by Simon Horman, change the code to handle the error case of fltr_base not found in the if condition. The code looks cleaner this way. Fixes: 8d7ba02 ("bnxt_en: Add support for ntuple filter deletion by ethtool.") Suggested-by: Simon Horman <horms@kernel.org> Reported-by: Jakub Kicinski <kuba@kernel.org> Link: https://lore.kernel.org/netdev/20240104145955.5a6df702@kernel.org/ Signed-off-by: Michael Chan <michael.chan@broadcom.com> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://lore.kernel.org/r/20240105235439.28282-3-michael.chan@broadcom.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 1ef4cac commit fd77697

1 file changed

Lines changed: 11 additions & 10 deletions

File tree

drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1345,25 +1345,26 @@ static int bnxt_srxclsrldel(struct bnxt *bp, struct ethtool_rxnfc *cmd)
13451345
{
13461346
struct ethtool_rx_flow_spec *fs = &cmd->fs;
13471347
struct bnxt_filter_base *fltr_base;
1348+
struct bnxt_ntuple_filter *fltr;
13481349

13491350
rcu_read_lock();
13501351
fltr_base = bnxt_get_one_fltr_rcu(bp, bp->ntp_fltr_hash_tbl,
13511352
BNXT_NTP_FLTR_HASH_SIZE,
13521353
fs->location);
1353-
if (fltr_base) {
1354-
struct bnxt_ntuple_filter *fltr;
1355-
1356-
fltr = container_of(fltr_base, struct bnxt_ntuple_filter, base);
1354+
if (!fltr_base) {
13571355
rcu_read_unlock();
1358-
if (!(fltr->base.flags & BNXT_ACT_NO_AGING))
1359-
return -EINVAL;
1360-
bnxt_hwrm_cfa_ntuple_filter_free(bp, fltr);
1361-
bnxt_del_ntp_filter(bp, fltr);
1362-
return 0;
1356+
return -ENOENT;
13631357
}
13641358

1359+
fltr = container_of(fltr_base, struct bnxt_ntuple_filter, base);
1360+
if (!(fltr->base.flags & BNXT_ACT_NO_AGING)) {
1361+
rcu_read_unlock();
1362+
return -EINVAL;
1363+
}
13651364
rcu_read_unlock();
1366-
return -ENOENT;
1365+
bnxt_hwrm_cfa_ntuple_filter_free(bp, fltr);
1366+
bnxt_del_ntp_filter(bp, fltr);
1367+
return 0;
13671368
}
13681369

13691370
static u64 get_ethtool_ipv4_rss(struct bnxt *bp)

0 commit comments

Comments
 (0)