From 4ab5c9484a542b5da351757b094e2258f97f393a Mon Sep 17 00:00:00 2001 From: Levente Kurusa Date: Tue, 6 May 2014 11:52:21 +0200 Subject: [PATCH] qr: print_oops: implement guarding against recursive error in QR lib Avoid recursive errors in the QR library and/or encoding by implementing a variable that will check if process crashed. Bail out if that happens. Signed-off-by: Levente Kurusa --- kernel/print_oops.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/kernel/print_oops.c b/kernel/print_oops.c index bdbfed7..82b894f 100644 --- a/kernel/print_oops.c +++ b/kernel/print_oops.c @@ -35,6 +35,8 @@ static int buf_pos; static DEFINE_MUTEX(compr_mutex); static struct z_stream_s stream; +static int bug_in_code; + void qr_append(char *text) { size_t len; @@ -140,6 +142,13 @@ void print_qr_err(void) if (!qr_oops) return; + if (bug_in_code) { + printk(KERN_EMERG "QR encoding triggers an error. Disabling.\n"); + return; + } + + bug_in_code ++; + info = registered_fb[0]; if (!info) { printk(KERN_WARNING "Unable to get hand of a framebuffer!\n"); @@ -202,5 +211,6 @@ void print_qr_err(void) QRcode_free(qr); qr_compr_exit(); buf_pos = 0; + bug_in_code --; } -- 1.8.3.1