diff options
author | Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> | 2016-01-16 18:50:27 +0000 |
---|---|---|
committer | Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> | 2016-01-16 18:50:27 +0000 |
commit | a3712817a2eff0173e664162fc441ee7846f6ea0 (patch) | |
tree | 441663e56658209660de4d0e128ba1600e0a03e8 | |
parent | 1ca7c7ff1ba0f5ad43b6cc5b767853fa3248859c (diff) | |
download | ast2050-flashrom-a3712817a2eff0173e664162fc441ee7846f6ea0.zip ast2050-flashrom-a3712817a2eff0173e664162fc441ee7846f6ea0.tar.gz |
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>
-rw-r--r-- | serial.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -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 } |