From 21889c5e7e57fde81c5cf290c7b348bdabd2bf45 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Wed, 8 Jan 2014 18:42:39 +0100 Subject: [PATCH] uds: take the interface data off the stack. The 'struct interface' for the UDS port is allocated on the stack, and when this gets passed to port_open, the port instance takes a pointer to the string in the 'name' field. Currently this is harmless for the UDS port, but it is not good form. This patch fixes the issue by making the interface part of the clock instance. Signed-off-by: Richard Cochran Reported-by: Miroslav Lichvar --- clock.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/clock.c b/clock.c index 063155b..c99812b 100644 --- a/clock.c +++ b/clock.c @@ -98,6 +98,7 @@ struct clock { struct clock_stats stats; int stats_interval; struct clockcheck *sanity_check; + struct interface uds_interface; }; struct clock the_clock; @@ -577,20 +578,19 @@ struct clock *clock_create(int phc_index, struct interface *iface, int count, int i, fadj = 0, max_adj = 0.0, sw_ts = timestamping == TS_SOFTWARE ? 1 : 0; struct clock *c = &the_clock; char phc[32]; - struct interface udsif; + struct interface *udsif = &c->uds_interface; struct timespec ts; - memset(&udsif, 0, sizeof(udsif)); - snprintf(udsif.name, sizeof(udsif.name), "%s", uds_path); - udsif.transport = TRANS_UDS; - udsif.delay_filter_length = 1; - clock_gettime(CLOCK_REALTIME, &ts); srandom(ts.tv_sec ^ ts.tv_nsec); if (c->nports) clock_destroy(c); + snprintf(udsif->name, sizeof(udsif->name), "%s", uds_path); + udsif->transport = TRANS_UDS; + udsif->delay_filter_length = 1; + c->free_running = dds->free_running; c->freq_est_interval = dds->freq_est_interval; c->grand_master_capable = dds->grand_master_capable; @@ -696,7 +696,7 @@ struct clock *clock_create(int phc_index, struct interface *iface, int count, /* * One extra port is for the UDS interface. */ - c->port[i] = port_open(phc_index, timestamping, 0, &udsif, c); + c->port[i] = port_open(phc_index, timestamping, 0, udsif, c); if (!c->port[i]) { pr_err("failed to open the UDS port"); return NULL;