If the RTC file descriptor was closed and removed after a read error,
don't try to close and remove it again in the driver finalization to
avoid an assertion failure on the negative descriptor.
Fixes: 4f22883f4e71 ("refclock: add new refclock for RTCs")
rtc = RCL_GetDriverData(instance);
- if (!rtc->polling) {
- SCH_RemoveFileHandler(rtc->fd);
- RTC_Linux_SwitchInterrupt(rtc->fd, 0);
+ if (rtc->fd >= 0) {
+ if (!rtc->polling) {
+ SCH_RemoveFileHandler(rtc->fd);
+ RTC_Linux_SwitchInterrupt(rtc->fd, 0);
+ }
+
+ close(rtc->fd);
}
- close(rtc->fd);
Free(rtc);
}