vbnv: Initialize variables that may be checked later
Set the buffer variables to NULL so that if flashrom fails then they
are not attempted to be freed.
BUG=b:37503158
BRANCH=none
TEST=remove flashrom binary, run 'mosys nvram vboot read'
Change-Id: I069d1874324fd9746d692cadfaee367e3890ae47
Signed-off-by: Duncan Laurie <dlaurie@google.com>
Reviewed-on: https://chromium-review.googlesource.com/481983
Reviewed-by: David Hendricks <dhendrix@chromium.org>
Reviewed-by: Furquan Shaikh <furquan@chromium.org>
diff --git a/lib/vbnv/vbnv_flash.c b/lib/vbnv/vbnv_flash.c
index a8970a4..91f076d 100644
--- a/lib/vbnv/vbnv_flash.c
+++ b/lib/vbnv/vbnv_flash.c
@@ -42,7 +42,7 @@
#include "mosys/output.h"
#include "mosys/platform.h"
- /* VBNV entries are 16 bytes each and are stored back-to-back in RW_NVRAM. */
+/* VBNV entries are 16 bytes each and are stored back-to-back in RW_NVRAM. */
#define VBNV_BLOCK_SIZE 16
/*
@@ -149,7 +149,7 @@
{
struct eeprom *eeprom = NULL;
struct eeprom_region *region = NULL;
- uint8_t *data;
+ uint8_t *data = NULL;
int ret = -1, bytes_read, index;
if (vbnv_find_eeprom(intf, &eeprom, ®ion))
@@ -208,7 +208,7 @@
{
struct eeprom *eeprom = NULL;
struct eeprom_region *region = NULL;
- uint8_t *buf;
+ uint8_t *buf = NULL;
int ret = -1, len, index;
if (vbnv_find_eeprom(intf, &eeprom, ®ion))