From b6d91753fc6afed85e1bce520898a9bdfa4db4a9 Mon Sep 17 00:00:00 2001 From: Jacob Garber Date: Wed, 27 Mar 2019 20:41:34 -0600 Subject: [PATCH] payloads/coreinfo: Free buffer before returning This fixes a memory leak, which was partially resolved in 2d1e0eb (payloads/coreinfo: Free buffer before returning). Found-by: Coverity Scan, CID 1373370 (RESOURCE_LEAK) Signed-off-by: Jacob Garber Change-Id: I0efe94b9dfb27746828055427029c01c7f407ec2 Reviewed-on: https://review.coreboot.org/c/coreboot/+/32094 Reviewed-by: Paul Menzel Reviewed-by: Patrick Rudolph Tested-by: build bot (Jenkins) --- payloads/coreinfo/timestamps_module.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/payloads/coreinfo/timestamps_module.c b/payloads/coreinfo/timestamps_module.c index 0978f319b0..fe2d2b5c6b 100644 --- a/payloads/coreinfo/timestamps_module.c +++ b/payloads/coreinfo/timestamps_module.c @@ -203,8 +203,10 @@ static int timestamps_module_init(void) SCREEN_X, LINES_SHOWN); /* Sanity check, chars_count must be padded to full line */ - if (chars_count % SCREEN_X != 0) + if (chars_count % SCREEN_X != 0) { + free(buffer); return -2; + } g_lines_count = chars_count / SCREEN_X; g_max_cursor_line = MAX(g_lines_count - 1 - LINES_SHOWN, 0);