Skip to content

Commit 9c6b9cb

Browse files
liyanguoCoriginekuba-moo
authored andcommitted
nfp: flower: avoid taking mutex in atomic context
A mutex may sleep, which is not permitted in atomic context. Avoid a case where this may arise by moving the to nfp_flower_lag_get_info_from_netdev() in nfp_tun_write_neigh() spinlock. Fixes: abc2109 ("nfp: flower: tunnel neigh support bond offload") Reported-by: Dan Carpenter <[email protected]> Signed-off-by: Yanguo Li <[email protected]> Signed-off-by: Simon Horman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent cca6e9f commit 9c6b9cb

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

drivers/net/ethernet/netronome/nfp/flower/tunnel_conf.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ nfp_tun_write_neigh(struct net_device *netdev, struct nfp_app *app,
460460
sizeof(struct nfp_tun_neigh_v4);
461461
unsigned long cookie = (unsigned long)neigh;
462462
struct nfp_flower_priv *priv = app->priv;
463+
struct nfp_tun_neigh_lag lag_info;
463464
struct nfp_neigh_entry *nn_entry;
464465
u32 port_id;
465466
u8 mtype;
@@ -468,6 +469,11 @@ nfp_tun_write_neigh(struct net_device *netdev, struct nfp_app *app,
468469
if (!port_id)
469470
return;
470471

472+
if ((port_id & NFP_FL_LAG_OUT) == NFP_FL_LAG_OUT) {
473+
memset(&lag_info, 0, sizeof(struct nfp_tun_neigh_lag));
474+
nfp_flower_lag_get_info_from_netdev(app, netdev, &lag_info);
475+
}
476+
471477
spin_lock_bh(&priv->predt_lock);
472478
nn_entry = rhashtable_lookup_fast(&priv->neigh_table, &cookie,
473479
neigh_table_params);
@@ -515,7 +521,7 @@ nfp_tun_write_neigh(struct net_device *netdev, struct nfp_app *app,
515521
neigh_ha_snapshot(common->dst_addr, neigh, netdev);
516522

517523
if ((port_id & NFP_FL_LAG_OUT) == NFP_FL_LAG_OUT)
518-
nfp_flower_lag_get_info_from_netdev(app, netdev, lag);
524+
memcpy(lag, &lag_info, sizeof(struct nfp_tun_neigh_lag));
519525
common->port_id = cpu_to_be32(port_id);
520526

521527
if (rhashtable_insert_fast(&priv->neigh_table,

0 commit comments

Comments
 (0)