diff options
author | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2020-09-14 10:01:00 +0200 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2020-09-22 12:54:13 -0600 |
commit | e5b35f706d13c8c0fffcf7b2af9c6df4f4190c5d (patch) | |
tree | ea457a190f382e0a317c501fd0a360b5cdbbedc6 /common/log.c | |
parent | 01d89e3d12e07a1a1ee0f8528706441a84eee328 (diff) | |
download | u-boot-e5b35f706d13c8c0fffcf7b2af9c6df4f4190c5d.tar.gz u-boot-e5b35f706d13c8c0fffcf7b2af9c6df4f4190c5d.tar.bz2 u-boot-e5b35f706d13c8c0fffcf7b2af9c6df4f4190c5d.zip |
log: mute messages generated by log drivers
When a message is written by a log driver (e.g. via the network stack) this
may result in the generation of further messages. We cannot allow these
additional messages to be emitted as this might result in an infinite
recursion.
Up to now only the syslog driver was safeguarded. We should safeguard all
log drivers instead.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'common/log.c')
-rw-r--r-- | common/log.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/common/log.c b/common/log.c index 734d26de4a..9a5f100da3 100644 --- a/common/log.c +++ b/common/log.c @@ -191,12 +191,23 @@ static bool log_passes_filters(struct log_device *ldev, struct log_rec *rec) static int log_dispatch(struct log_rec *rec) { struct log_device *ldev; + static int processing_msg; + /* + * When a log driver writes messages (e.g. via the network stack) this + * may result in further generated messages. We cannot process them here + * as this might result in infinite recursion. + */ + if (processing_msg) + return 0; + + /* Emit message */ + processing_msg = 1; list_for_each_entry(ldev, &gd->log_head, sibling_node) { if (log_passes_filters(ldev, rec)) ldev->drv->emit(ldev, rec); } - + processing_msg = 0; return 0; } |