[flashrom] [commit] r1778 - trunk

repository service svn at flashrom.org
Sat Apr 26 18:12:46 CEST 2014


Author: stefanct
Date: Sat Apr 26 18:12:45 2014
New Revision: 1778
URL: http://flashrom.org/trac/flashrom/changeset/1778

Log:
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 at coreboot.org>
Signed-off-by: Stefan Tauner <stefan.tauner at alumni.tuwien.ac.at>
Acked-by: Stefan Tauner <stefan.tauner at alumni.tuwien.ac.at>

Modified:
   trunk/buspirate_spi.c

Modified: trunk/buspirate_spi.c
==============================================================================
--- trunk/buspirate_spi.c	Sat Apr 26 18:12:31 2014	(r1777)
+++ trunk/buspirate_spi.c	Sat Apr 26 18:12:45 2014	(r1778)
@@ -250,6 +250,7 @@
 	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 @@
 		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




More information about the flashrom mailing list