Patrick Georgi (patrick@georgi-clan.de) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/6561
-gerrit
commit 29f7cd291d4e931d51af1efa103941c705e83cb9 Author: Patrick Georgi patrick@georgi-clan.de Date: Sat Aug 9 17:06:20 2014 +0200
nvramtool: plug some memory leaks
Change-Id: I8f672b872862d3448ccd2cf28fd3c05b0108ff8b Found-by: Coverity Scan Signed-off-by: Patrick Georgi patrick@georgi-clan.de --- util/nvramtool/cmos_lowlevel.c | 1 + util/nvramtool/cmos_ops.c | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/util/nvramtool/cmos_lowlevel.c b/util/nvramtool/cmos_lowlevel.c index ef0c383..bc237c1 100644 --- a/util/nvramtool/cmos_lowlevel.c +++ b/util/nvramtool/cmos_lowlevel.c @@ -142,6 +142,7 @@ unsigned long long cmos_read(const cmos_entry_t * e) usize]); result = (unsigned long)newstring; } + free(newstring); } else { for (next_bit = 0, bits_left = length; bits_left; next_bit += nr_bits, bits_left -= nr_bits) { diff --git a/util/nvramtool/cmos_ops.c b/util/nvramtool/cmos_ops.c index 91c9f45..cb6c379 100644 --- a/util/nvramtool/cmos_ops.c +++ b/util/nvramtool/cmos_ops.c @@ -95,7 +95,7 @@ int prepare_cmos_write(const cmos_entry_t * e, const char value_str[], const cmos_enum_t *q; unsigned long long out; const char *p; - char *memory; + char *memory = NULL; int negative, result, found_one;
if ((result = prepare_cmos_op_common(e)) != OK) @@ -155,8 +155,10 @@ int prepare_cmos_write(const cmos_entry_t * e, const char value_str[], BUG(); }
- if ((e->length < (8 * sizeof(*value))) && (out >= (1ull << e->length))) + if ((e->length < (8 * sizeof(*value))) && (out >= (1ull << e->length))) { + if (memory) free(memory); return CMOS_OP_VALUE_TOO_WIDE; + }
*value = out; return OK;