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 <liuhangbin@gmail.com>
master
Hangbin Liu 2017-06-23 11:22:45 +08:00 committed by Richard Cochran
parent 6b18e12b9b
commit 46cc187e82
1 changed files with 11 additions and 0 deletions

View File

@ -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: