nvramtool: plug some memory leaks

Change-Id: I8f672b872862d3448ccd2cf28fd3c05b0108ff8b
Found-by: Coverity Scan
Signed-off-by: Patrick Georgi <patrick@georgi-clan.de>
Reviewed-on: http://review.coreboot.org/6561
Tested-by: build bot (Jenkins)
Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
This commit is contained in:
Patrick Georgi
2014-08-09 17:06:20 +02:00
parent 42b1b8069c
commit dd1aab95a6
2 changed files with 8 additions and 3 deletions

View File

@ -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;