[Linuxptp-devel] [PATCH v2] ts2phc: Fix potential null-pointer dereference
PTP IEEE 1588 stack for Linux
Brought to you by:
rcochran
From: Maciek M. <ma...@ma...> - 2023-03-13 20:32:09
|
An unallocated pmc_agent may be dereferenced in the pmc_agent_destroy called by the ts2phc_cleanup(). Check if the agent was allocated before releasing it. v2: Fixed coding standard Signed-off-by: Maciek Machnikowski <ma...@ma...> --- ts2phc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ts2phc.c b/ts2phc.c index 4393059..db5ea3f 100644 --- a/ts2phc.c +++ b/ts2phc.c @@ -38,7 +38,8 @@ static void ts2phc_cleanup(struct ts2phc_private *priv) if (priv->cfg) config_destroy(priv->cfg); - pmc_agent_destroy(priv->agent); + if (priv->agent) + pmc_agent_destroy(priv->agent); /* * Clocks are destroyed by the cleanup methods of the individual -- 2.37.1 (Apple Git-137.1) |