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 <richardcochran@gmail.com> Reported-by: Miroslav Lichvar <mlichvar@redhat.com>master
parent
5dd5af5565
commit
21889c5e7e
14
clock.c
14
clock.c
|
@ -98,6 +98,7 @@ struct clock {
|
||||||
struct clock_stats stats;
|
struct clock_stats stats;
|
||||||
int stats_interval;
|
int stats_interval;
|
||||||
struct clockcheck *sanity_check;
|
struct clockcheck *sanity_check;
|
||||||
|
struct interface uds_interface;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct clock the_clock;
|
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;
|
int i, fadj = 0, max_adj = 0.0, sw_ts = timestamping == TS_SOFTWARE ? 1 : 0;
|
||||||
struct clock *c = &the_clock;
|
struct clock *c = &the_clock;
|
||||||
char phc[32];
|
char phc[32];
|
||||||
struct interface udsif;
|
struct interface *udsif = &c->uds_interface;
|
||||||
struct timespec ts;
|
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);
|
clock_gettime(CLOCK_REALTIME, &ts);
|
||||||
srandom(ts.tv_sec ^ ts.tv_nsec);
|
srandom(ts.tv_sec ^ ts.tv_nsec);
|
||||||
|
|
||||||
if (c->nports)
|
if (c->nports)
|
||||||
clock_destroy(c);
|
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->free_running = dds->free_running;
|
||||||
c->freq_est_interval = dds->freq_est_interval;
|
c->freq_est_interval = dds->freq_est_interval;
|
||||||
c->grand_master_capable = dds->grand_master_capable;
|
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.
|
* 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]) {
|
if (!c->port[i]) {
|
||||||
pr_err("failed to open the UDS port");
|
pr_err("failed to open the UDS port");
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
Loading…
Reference in New Issue