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.

Signed-off-by: Maciek Machnikowski <mac...@machnikowski.net>
---
 ts2phc.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ts2phc.c b/ts2phc.c
index 4393059..ba08f99 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)



_______________________________________________
Linuxptp-devel mailing list
Linuxptp-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxptp-devel

Reply via email to