summaryrefslogtreecommitdiffstats
path: root/print.c
diff options
context:
space:
mode:
authorStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2011-06-26 20:45:35 +0000
committerStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2011-06-26 20:45:35 +0000
commit00155498a86e2c77ee6c08d274fa7954f38a56f6 (patch)
tree25c2fba44df4a8c7e9ec5289036a611760f84b9b /print.c
parentb23df71149f39c45952778c5fe11ef76094d8719 (diff)
downloadflashrom-00155498a86e2c77ee6c08d274fa7954f38a56f6.tar.gz
flashrom-00155498a86e2c77ee6c08d274fa7954f38a56f6.tar.bz2
flashrom-00155498a86e2c77ee6c08d274fa7954f38a56f6.zip
Fix memleaks due to incorrect usage of flashbuses_to_text
Corresponding to flashrom svn r1357. Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Diffstat (limited to 'print.c')
-rw-r--r--print.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/print.c b/print.c
index 28c0e1818..b9f7a4362 100644
--- a/print.c
+++ b/print.c
@@ -28,7 +28,7 @@
/*
* Return a string corresponding to the bustype parameter.
- * Memory is obtained with malloc() and can be freed with free().
+ * Memory is obtained with malloc() and must be freed with free() by the caller.
*/
char *flashbuses_to_text(enum chipbustype bustype)
{
@@ -80,6 +80,7 @@ static void print_supported_chips(void)
int maxvendorlen = strlen("Vendor") + 1;
int maxchiplen = strlen("Device") + 1;
const struct flashchip *f;
+ char *s;
for (f = flashchips; f->name != NULL; f++) {
/* Ignore "unknown XXXX SPI chip" entries. */
@@ -152,7 +153,10 @@ static void print_supported_chips(void)
msg_ginfo("%d", f->total_size);
for (i = 0; i < 10 - digits(f->total_size); i++)
msg_ginfo(" ");
- msg_ginfo("%s\n", flashbuses_to_text(f->bustype));
+
+ s = flashbuses_to_text(f->bustype);
+ msg_ginfo("%s\n", s);
+ free(s);
}
}