phc2sys: fix PPS mode with no source clock.
When using a PPS source with no source clock specified with the -s option, avoid referencing a NULL pointer and using CLOCK_INVALID in system calls. Signed-off-by: Miroslav Lichvar <mlichvar@redhat.com>master
parent
966eff0161
commit
a335ac556a
|
@ -221,7 +221,7 @@ static struct clock *clock_add(struct node *node, char *device)
|
||||||
c->clkid = clkid;
|
c->clkid = clkid;
|
||||||
c->phc_index = phc_index;
|
c->phc_index = phc_index;
|
||||||
c->servo_state = SERVO_UNLOCKED;
|
c->servo_state = SERVO_UNLOCKED;
|
||||||
c->device = strdup(device);
|
c->device = device ? strdup(device) : NULL;
|
||||||
|
|
||||||
if (c->clkid == CLOCK_REALTIME) {
|
if (c->clkid == CLOCK_REALTIME) {
|
||||||
c->source_label = "sys";
|
c->source_label = "sys";
|
||||||
|
@ -249,9 +249,10 @@ static struct clock *clock_add(struct node *node, char *device)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (clkid != CLOCK_INVALID)
|
||||||
c->servo = servo_add(node, c);
|
c->servo = servo_add(node, c);
|
||||||
|
|
||||||
if (clkid != CLOCK_REALTIME)
|
if (clkid != CLOCK_INVALID && clkid != CLOCK_REALTIME)
|
||||||
c->sysoff_supported = (SYSOFF_SUPPORTED ==
|
c->sysoff_supported = (SYSOFF_SUPPORTED ==
|
||||||
sysoff_probe(CLOCKID_TO_FD(clkid),
|
sysoff_probe(CLOCKID_TO_FD(clkid),
|
||||||
node->phc_readings));
|
node->phc_readings));
|
||||||
|
|
Loading…
Reference in New Issue