From 2ba4d71d288b9d9705c039cc537d24a0e707b679 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonathan=20Neusch=C3=A4fer?= Date: Tue, 9 Aug 2016 15:01:58 +0200 Subject: [PATCH] UPSTREAM: util/cbfstool: Initialize elf_writer pointer to avoid crash If some error happens in cbfs_payload_make_elf, the code jumps to "out", and elf_writer_destroy(ew) is called. This may happen before an elf writer is allocated. To avoid accessing an uninitialized pointer, initialize ew to NULL; elf_writer_destroy will perform no action in this case. BUG=None BRANCH=None TEST=None Signed-off-by: Jonathan Neuschfer Reviewed-on: https://review.coreboot.org/16124 Reviewed-by: Aaron Durbin Change-Id: I5f1f9c4d37f2bdeaaeeca7a15720c7b4c963d953 Reviewed-on: https://chromium-review.googlesource.com/369111 Commit-Ready: Furquan Shaikh Tested-by: Furquan Shaikh --- util/cbfstool/cbfs_image.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/cbfstool/cbfs_image.c b/util/cbfstool/cbfs_image.c index 50fc64cab9..6dc47c73dc 100644 --- a/util/cbfstool/cbfs_image.c +++ b/util/cbfstool/cbfs_image.c @@ -1052,7 +1052,7 @@ static int cbfs_payload_make_elf(struct buffer *buff, uint32_t arch) Elf64_Ehdr ehdr; Elf64_Shdr shdr; struct cbfs_payload_segment *segs = NULL; - struct elf_writer *ew; + struct elf_writer *ew = NULL; struct buffer elf_out; int segments = 0; int retval = -1;