Author: stefanct Date: Sat Jan 16 19:50:27 2016 New Revision: 1915 URL: http://flashrom.org/trac/flashrom/changeset/1915
Log: Fix file descriptor leak in serial.c.
Found by Coverity as "CID 1348465: Resource leaks".
Signed-off-by: Stefan Tauner stefan.tauner@alumni.tuwien.ac.at Acked-by: Stefan Tauner stefan.tauner@alumni.tuwien.ac.at
Modified: trunk/serial.c
Modified: trunk/serial.c ============================================================================== --- trunk/serial.c Fri Jan 15 00:05:55 2016 (r1914) +++ trunk/serial.c Sat Jan 16 19:50:27 2016 (r1915) @@ -282,18 +282,20 @@ 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 }