Commit 11664948 authored by John Hurley's avatar John Hurley Committed by David S. Miller

nfp: flower: release metadata on offload failure

Calling nfp_compile_flow_metadata both assigns a stats context and
increments a ref counter on (or allocates) a mask id table entry. These
are released by the nfp_modify_flow_metadata call on flow deletion,
however, if a flow add fails after metadata is set then the flow entry
will be deleted but the metadata assignments leaked.

Add an error path to the flow add offload function to ensure allocated
metadata is released in the event of an offload fail.

Fixes: 81f3ddf2 ("nfp: add control message passing capabilities to flower offloads")
Signed-off-by: default avatarJohn Hurley <john.hurley@netronome.com>
Reviewed-by: default avatarPieter Jansen van Vuuren <pieter.jansenvanvuuren@netronome.com>
Reviewed-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3b5b3a33
...@@ -479,13 +479,13 @@ nfp_flower_add_offload(struct nfp_app *app, struct net_device *netdev, ...@@ -479,13 +479,13 @@ nfp_flower_add_offload(struct nfp_app *app, struct net_device *netdev,
err = nfp_flower_xmit_flow(netdev, flow_pay, err = nfp_flower_xmit_flow(netdev, flow_pay,
NFP_FLOWER_CMSG_TYPE_FLOW_ADD); NFP_FLOWER_CMSG_TYPE_FLOW_ADD);
if (err) if (err)
goto err_destroy_flow; goto err_release_metadata;
flow_pay->tc_flower_cookie = flow->cookie; flow_pay->tc_flower_cookie = flow->cookie;
err = rhashtable_insert_fast(&priv->flow_table, &flow_pay->fl_node, err = rhashtable_insert_fast(&priv->flow_table, &flow_pay->fl_node,
nfp_flower_table_params); nfp_flower_table_params);
if (err) if (err)
goto err_destroy_flow; goto err_release_metadata;
port->tc_offload_cnt++; port->tc_offload_cnt++;
...@@ -494,6 +494,8 @@ nfp_flower_add_offload(struct nfp_app *app, struct net_device *netdev, ...@@ -494,6 +494,8 @@ nfp_flower_add_offload(struct nfp_app *app, struct net_device *netdev,
return 0; return 0;
err_release_metadata:
nfp_modify_flow_metadata(app, flow_pay);
err_destroy_flow: err_destroy_flow:
kfree(flow_pay->action_data); kfree(flow_pay->action_data);
kfree(flow_pay->mask_data); kfree(flow_pay->mask_data);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment