summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-05-13 08:04:44 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2015-05-15 07:01:42 +0200
commitc82d18f0f6df06c00e4ab131879c4adf1b08ad0b (patch)
tree5e60bee63ef6ddb80eafb671f20a26257a0787d7 /common
parent74a96ab0077f7010cbec6c1f1182ce2ea4fabc6b (diff)
downloadbarebox-c82d18f0f6df06c00e4ab131879c4adf1b08ad0b.tar.gz
barebox-c82d18f0f6df06c00e4ab131879c4adf1b08ad0b.tar.xz
console: use regular malloc for log messages
Using xfunctions to allocate log messages is not a good idea. Should we be out of memory the xfunctions will panic which will cause another allocation, so we deadlock the system with no message going out. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r--common/console_common.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/common/console_common.c b/common/console_common.c
index 41a6929dba..36bd1dd9e8 100644
--- a/common/console_common.c
+++ b/common/console_common.c
@@ -106,15 +106,23 @@ static void pr_puts(int level, const char *str)
log_clean(barebox_log_max_messages - 1);
if (barebox_log_max_messages >= 0) {
- log = xzalloc(sizeof(*log));
- log->msg = xstrdup(str);
+ log = malloc(sizeof(*log));
+ if (!log)
+ goto nolog;
+
+ log->msg = strdup(str);
+ if (!log->msg) {
+ free(log);
+ goto nolog;
+ }
+
log->timestamp = get_time_ns();
log->level = level;
list_add_tail(&log->list, &barebox_logbuf);
barebox_logbuf_num_messages++;
}
}
-
+nolog:
if (level > barebox_loglevel)
return;