diff options
author | stefanct <stefanct@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1> | 2014-04-26 16:12:45 +0000 |
---|---|---|
committer | stefanct <stefanct@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1> | 2014-04-26 16:12:45 +0000 |
commit | 34c3f038873c26e0b599650f4f2b4af419b52227 (patch) | |
tree | d8118a4e310604b1c154bf9dd01225eb44d59d7a /buspirate_spi.c | |
parent | 16c34902d0899a51fabd730cc6a9417c12e355a3 (diff) | |
download | flashrom-34c3f038873c26e0b599650f4f2b4af419b52227.tar.gz |
CID1130006: Memory leaks in buspirate_spi_init().
The one in the error case of register_shutdown() was discovered while
reviewing the other one found by Coverity and fixed by Stefan Reinauer.
Signed-off-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@1778 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'buspirate_spi.c')
-rw-r--r-- | buspirate_spi.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/buspirate_spi.c b/buspirate_spi.c index 9d229f4..f0e84bc 100644 --- a/buspirate_spi.c +++ b/buspirate_spi.c @@ -250,6 +250,7 @@ int buspirate_spi_init(void) if (!bp_commbuf) { bp_commbufsize = 0; msg_perr("Out of memory!\n"); + free(dev); return ERROR_OOM; } bp_commbufsize = DEFAULT_BUFSIZE; @@ -263,8 +264,12 @@ int buspirate_spi_init(void) return ret; } - if (register_shutdown(buspirate_spi_shutdown, NULL)) + if (register_shutdown(buspirate_spi_shutdown, NULL) != 0) { + bp_commbufsize = 0; + free(bp_commbuf); + bp_commbuf = NULL; return 1; + } /* This is the brute force version, but it should work. * It is likely to fail if a previous flashrom run was aborted during a write with the new SPI commands |