timerfd_create(): Fix error handling of osmo_fd_register()

Change-Id: Ia2528cc3e3155bbc9cb32dee0e3af99cc6e1c654
Closes: Coverity CID#188853
This commit is contained in:
Harald Welte 2018-10-21 12:32:55 +02:00
parent 41b6b5e3fc
commit 37608f911d
1 changed files with 8 additions and 1 deletions

View File

@ -324,11 +324,18 @@ int osmo_timerfd_setup(struct osmo_fd *ofd, int (*cb)(struct osmo_fd *, unsigned
ofd->when = BSC_FD_READ;
if (ofd->fd < 0) {
int rc;
ofd->fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);
if (ofd->fd < 0)
return ofd->fd;
osmo_fd_register(ofd);
rc = osmo_fd_register(ofd);
if (rc < 0) {
close(ofd->fd);
ofd->fd = -1;
return rc;
}
}
return 0;
}