Hangbin Liu
2017-06-22 14:36:33 UTC
Since we called strdup() for clock device, we need free the memory
before exit.
Signed-off-by: Hangbin Liu <***@gmail.com>
---
phc2sys.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/phc2sys.c b/phc2sys.c
index 68db5af..41a9053 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -245,6 +245,16 @@ static struct clock *clock_add(struct node *node, char *device)
return c;
}
+static void clock_destroy(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;
@@ -1544,6 +1554,7 @@ int main(int argc, char *argv[])
end:
if (node.pmc)
close_pmc(&node);
+ clock_destroy(&node);
config_destroy(cfg);
return r;
bad_usage:
before exit.
Signed-off-by: Hangbin Liu <***@gmail.com>
---
phc2sys.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/phc2sys.c b/phc2sys.c
index 68db5af..41a9053 100644
--- a/phc2sys.c
+++ b/phc2sys.c
@@ -245,6 +245,16 @@ static struct clock *clock_add(struct node *node, char *device)
return c;
}
+static void clock_destroy(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;
@@ -1544,6 +1554,7 @@ int main(int argc, char *argv[])
end:
if (node.pmc)
close_pmc(&node);
+ clock_destroy(&node);
config_destroy(cfg);
return r;
bad_usage:
--
2.5.5
2.5.5