From 46cc187e82874423f3a0940d8b12c191f7455a1a Mon Sep 17 00:00:00 2001 From: Hangbin Liu Date: Fri, 23 Jun 2017 11:22:45 +0800 Subject: [PATCH] phc2sys: free clock device when exit Since we called strdup() for clock device, we need free the memory before exit. Signed-off-by: Hangbin Liu --- phc2sys.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/phc2sys.c b/phc2sys.c index 8161d92..b6f6719 100644 --- a/phc2sys.c +++ b/phc2sys.c @@ -240,6 +240,16 @@ static struct clock *clock_add(struct node *node, char *device) return c; } +static void clock_cleanup(struct node *node) +{ + struct clock *c; + + LIST_FOREACH(c, &node->clocks, list) { + if (c->device) + free(c->device); + } +} + static struct port *port_get(struct node *node, unsigned int number) { struct port *p; @@ -1506,6 +1516,7 @@ int main(int argc, char *argv[]) end: if (node.pmc) close_pmc(&node); + clock_cleanup(&node); config_destroy(cfg); return r; bad_usage: