1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-26 22:52:34 +02:00

Fix file descriptor leak in serial.c

Found by Coverity as "CID 1348465:  Resource leaks".

Corresponding to flashrom svn r1915.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
This commit is contained in:
Stefan Tauner 2016-01-16 18:50:27 +00:00
parent 1ca7c7ff1b
commit a3712817a2

View File

@ -282,18 +282,20 @@ fdtype sp_openserport(char *dev, int baud)
const int flags = fcntl(fd, F_GETFL);
if (flags == -1) {
msg_perr_strerror("Could not get serial port mode: ");
return SER_INV_FD;
goto err;
}
if (fcntl(fd, F_SETFL, flags & ~O_NONBLOCK) != 0) {
msg_perr_strerror("Could not set serial port mode to blocking: ");
return SER_INV_FD;
goto err;
}
if (serialport_config(fd, baud) != 0) {
close(fd);
return SER_INV_FD;
goto err;
}
return fd;
err:
close(fd);
return SER_INV_FD;
#endif
}