mirror of
https://github.com/vsergeev/c-periphery.git
synced 2026-09-22 12:43:46 +08:00
serial: clear handle fd on error to prevent spurious close() in serial_close()
This commit is contained in:
@@ -232,6 +232,7 @@ int serial_open_advanced(serial_t *serial, const char *path, uint32_t baudrate,
|
||||
if (tcsetattr(serial->fd, TCSANOW, &termios_settings) < 0) {
|
||||
int errsv = errno;
|
||||
close(serial->fd);
|
||||
serial->fd = -1;
|
||||
return _serial_error(serial, SERIAL_ERROR_CONFIGURE, errsv, "Setting serial port attributes");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user