From: Arve Hjønnevåg Date: Tue, 15 Apr 2008 04:35:25 +0000 (-0700) Subject: printk: Fix log_buf_copy termination. X-Git-Tag: firefly_0821_release~9833^2~5^2~268 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=703a8808cce6c97ca9bcb824bef77a5a306bbe92;p=firefly-linux-kernel-4.4.55.git printk: Fix log_buf_copy termination. If idx was non-zero and the log had wrapped, len did not get truncated to stop at the last byte written to the log. --- diff --git a/kernel/printk.c b/kernel/printk.c index 33d6dcdb4909..2d594092d3e1 100644 --- a/kernel/printk.c +++ b/kernel/printk.c @@ -290,8 +290,8 @@ int log_buf_copy(char *dest, int idx, int len) if (idx < 0 || idx >= max) { ret = -1; } else { - if (len > max) - len = max; + if (len > max - idx) + len = max - idx; ret = len; idx += (log_end - max); while (len-- > 0)