From 7b952265292f288131571e2c796c009347d35107 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 25 Apr 2013 17:21:58 -0700 Subject: [PATCH] elog: Make sure the elog data structures are initialized in elog_clear. If elog_clear is called before other elog functions, for instance if it's called through an SMI immediately after the system boots, then the elog data structures won't have been set up and the system will go off the deep end. This change adds a call to elog_init to elog_clear to make sure things things are always initialized before we start using them. BUG=chrome-os-partner:18734 TEST=Built and booted on Link. Before this change, this command would cause the system to lock up if run immediately after boot: echo 1 > /sys/firmware/gsmi/clear_eventlog After this change, that results in the log being cleared correctly. BRANCH=None Change-Id: I45027f0dbfa40ca8c581954a93b14b4fedce91ed Signed-off-by: Gabe Black Reviewed-on: https://gerrit.chromium.org/gerrit/49303 Reviewed-by: Duncan Laurie Reviewed-by: Stefan Reinauer Commit-Queue: Gabe Black Tested-by: Gabe Black --- src/drivers/elog/elog.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/drivers/elog/elog.c b/src/drivers/elog/elog.c index 1a794d90ab..710cf684ca 100644 --- a/src/drivers/elog/elog.c +++ b/src/drivers/elog/elog.c @@ -746,6 +746,10 @@ int elog_clear(void) elog_debug("elog_clear()\n"); + /* Make sure ELOG structures are initialized */ + if (elog_init() < 0) + return -1; + /* Erase flash area */ elog_flash_erase_area();