dpif-netdev: Fix flow mark leak on port lookup failure.
Flow mark should be properly freed in all error cases.
Fixes: ("dpif-netdev: associate flow with a mark id")
Acked-By: Roni Bar Yanai
@@ -2383,7 +2383,7 @@ dp_netdev_flow_offload_put(struct dp_flow_offload_item *offload)
port = dp_netdev_lookup_port(pmd->dp, in_port);
if (!port) {
ovs_mutex_unlock(&pmd->dp->port_mutex);
- return -1;
+ goto err_free;
}
ret = netdev_flow_put(port->netdev, &offload->match,
CONST_CAST(struct nlattr *, offload->actions),
@@ -2392,20 +2392,22 @@ dp_netdev_flow_offload_put(struct dp_flow_offload_item *offload)
ovs_mutex_unlock(&pmd->dp->port_mutex);
if (ret) {
- if (!modification) {
- flow_mark_free(mark);
- } else {
- mark_to_flow_disassociate(pmd, flow);
- }
- return -1;
+ goto err_free;
}
if (!modification) {
megaflow_to_mark_associate(&flow->mega_ufid, mark);
mark_to_flow_associate(mark, flow);
}
-
return 0;
+
+err_free:
+ if (!modification) {
+ flow_mark_free(mark);
+ } else {
+ mark_to_flow_disassociate(pmd, flow);
+ }
+ return -1;
}
static void *
