Skip to content

Commit

Permalink
dpif-netdev: fix memory leak in dpif and mfex commands
Browse files Browse the repository at this point in the history
This patch fixes a memory leak in the commands for DPIF and MFEX
get and set. In order to operate the commands require a pmd_list,
which is currently not freed after it has been used. This issue
was identified by a static analysis tool.

Fixes: 3d8f47b ("dpif-netdev: Add command line and function pointer for miniflow extract")
Fixes: abb807e ("dpif-netdev: Add command to switch dpif implementation.")
Signed-off-by: Harry van Haaren <harry.van.haaren@intel.com>
Acked-by: Kevin Traynor <ktraynor@redhat.com>
Signed-off-by: Ian Stokes <ian.stokes@intel.com>
  • Loading branch information
harry-van-haaren authored and istokes committed Aug 16, 2021
1 parent 7f71602 commit 8025437
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/dpif-netdev.c
Expand Up @@ -1025,6 +1025,7 @@ dpif_netdev_impl_get(struct unixctl_conn *conn, int argc OVS_UNUSED,
* thread. */
sorted_poll_thread_list(dp, &pmd_list, &n);
dp_netdev_impl_get(&reply, pmd_list, n);
free(pmd_list);
}
ovs_mutex_unlock(&dp_netdev_mutex);
unixctl_command_reply(conn, ds_cstr(&reply));
Expand Down Expand Up @@ -1079,6 +1080,8 @@ dpif_netdev_impl_set(struct unixctl_conn *conn, int argc OVS_UNUSED,
atomic_uintptr_t *pmd_func = (void *) &pmd->netdev_input_func;
atomic_store_relaxed(pmd_func, (uintptr_t) default_func);
};

free(pmd_list);
}
ovs_mutex_unlock(&dp_netdev_mutex);

Expand Down Expand Up @@ -1109,6 +1112,7 @@ dpif_miniflow_extract_impl_get(struct unixctl_conn *conn, int argc OVS_UNUSED,
* thread. */
sorted_poll_thread_list(dp, &pmd_list, &n);
dp_mfex_impl_get(&reply, pmd_list, n);
free(pmd_list);
}
ovs_mutex_unlock(&dp_netdev_mutex);
unixctl_command_reply(conn, ds_cstr(&reply));
Expand Down Expand Up @@ -1266,6 +1270,8 @@ dpif_miniflow_extract_impl_set(struct unixctl_conn *conn, int argc,
atomic_uintptr_t *pmd_func = (void *) &pmd->miniflow_extract_opt;
atomic_store_relaxed(pmd_func, (uintptr_t) mfex_func);
};

free(pmd_list);
}

ovs_mutex_unlock(&dp_netdev_mutex);
Expand Down

0 comments on commit 8025437

Please sign in to comment.