serial: clear handle fd on error to prevent spurious close() in serial_close()

This commit is contained in:
Vanya A. Sergeev
2020-09-11 01:41:51 -05:00
parent 5081fe1cbc
commit c9bce3a5c2
+1
View File
@@ -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");
}