rtc: don't finalize driver if initialization failed
This commit is contained in:
parent
25bdee7a0e
commit
a57e1eb542
2 changed files with 12 additions and 13 deletions
2
rtc.c
2
rtc.c
|
@ -160,7 +160,7 @@ RTC_Initialise(int initial_set)
|
|||
void
|
||||
RTC_Finalise(void)
|
||||
{
|
||||
if (driver.fini) {
|
||||
if (driver_initialised) {
|
||||
(driver.fini)();
|
||||
}
|
||||
}
|
||||
|
|
23
rtc_linux.c
23
rtc_linux.c
|
@ -505,18 +505,7 @@ switch_interrupts(int on_off)
|
|||
int
|
||||
RTC_Linux_Initialise(void)
|
||||
{
|
||||
rtc_sec = MallocArray(time_t, MAX_SAMPLES);
|
||||
rtc_trim = MallocArray(double, MAX_SAMPLES);
|
||||
system_times = MallocArray(struct timespec, MAX_SAMPLES);
|
||||
|
||||
/* Setup details depending on configuration options */
|
||||
setup_config();
|
||||
|
||||
/* In case it didn't get done by pre-init */
|
||||
coefs_file_name = CNF_GetRtcFile();
|
||||
|
||||
/* Try to open device */
|
||||
|
||||
/* Try to open the device */
|
||||
fd = open(CNF_GetRtcDevice(), O_RDWR);
|
||||
if (fd < 0) {
|
||||
LOG(LOGS_ERR, "Could not open RTC device %s : %s",
|
||||
|
@ -527,6 +516,16 @@ RTC_Linux_Initialise(void)
|
|||
/* Close on exec */
|
||||
UTI_FdSetCloexec(fd);
|
||||
|
||||
rtc_sec = MallocArray(time_t, MAX_SAMPLES);
|
||||
rtc_trim = MallocArray(double, MAX_SAMPLES);
|
||||
system_times = MallocArray(struct timespec, MAX_SAMPLES);
|
||||
|
||||
/* Setup details depending on configuration options */
|
||||
setup_config();
|
||||
|
||||
/* In case it didn't get done by pre-init */
|
||||
coefs_file_name = CNF_GetRtcFile();
|
||||
|
||||
n_samples = 0;
|
||||
n_samples_since_regression = 0;
|
||||
n_runs = 0;
|
||||
|
|
Loading…
Reference in a new issue