From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6017CC07E9D for ; Sat, 24 Sep 2022 00:05:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233040AbiIXAFz (ORCPT ); Fri, 23 Sep 2022 20:05:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232315AbiIXAFK (ORCPT ); Fri, 23 Sep 2022 20:05:10 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F1C89DFAB; Fri, 23 Sep 2022 17:05:06 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1663977901; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=z4lcvDU/MemQOUY1h+3uqj4PoL4kor3zog3zDG/QSnM=; b=R2t99lC/EqCbqaf4XF8cFgE7FcfLjsAb+kOQ1Wfu6XGekrw/NG4KpclPNhRdYDcMjxba9S 78wtU8Ef2nRNsdoPjknjYM97lBHcPccJzPh241MNm5DeUXghIbK2Jp/Ezbmtgg/FZpwuE2 AVMTTTn5/Oprhvg3BBwZ7ddjTB23kOCIegspaNmHwvknTV2/n9FuEI/tTNP97VY3G3G9gq QtgvZF1bWUY91LCrfZ1ohbqtKc/gAfCur1rGkbJ6bVKnf+WVlnZC6mQuvsw5P7HPWEPWI2 2fuY49WOYSv6DT7AQUzsTYH1uDNqC86UTmVNkaxH7WnCSrp84o4SwlY4WIzd9g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1663977901; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=z4lcvDU/MemQOUY1h+3uqj4PoL4kor3zog3zDG/QSnM=; b=q7Tw6vty0oiILbyIcxbEZIBR6eTBTnRqhvzIU7ymOMavEnHnaBtUi5gMC7dJEYydCUR6Uj CRe60J2Koibhy6BQ== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Jason Wessel , Daniel Thompson , Douglas Anderson , Greg Kroah-Hartman , Jiri Slaby , kgdb-bugreport@lists.sourceforge.net, linux-serial@vger.kernel.org Subject: [PATCH printk 09/18] serial: kgdboc: Lock console list in probe function Date: Sat, 24 Sep 2022 02:10:45 +0206 Message-Id: <20220924000454.3319186-10-john.ogness@linutronix.de> In-Reply-To: <20220924000454.3319186-1-john.ogness@linutronix.de> References: <20220924000454.3319186-1-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Gleixner Unprotected list walks are not necessarily safe. Signed-off-by: Thomas Gleixner Signed-off-by: John Ogness Reviewed-by: Sergey Senozhatsky --- drivers/tty/serial/kgdboc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/tty/serial/kgdboc.c b/drivers/tty/serial/kgdboc.c index 79b7db8580e0..af2aa76bae15 100644 --- a/drivers/tty/serial/kgdboc.c +++ b/drivers/tty/serial/kgdboc.c @@ -193,7 +193,8 @@ static int configure_kgdboc(void) if (!p) goto noconfig; - for_each_console(cons) { + console_list_lock(); + for_each_registered_console(cons) { int idx; if (cons->device && cons->device(cons, &idx) == p && idx == tty_line) { @@ -201,6 +202,7 @@ static int configure_kgdboc(void) break; } } + console_list_unlock(); kgdb_tty_driver = p; kgdb_tty_line = tty_line; -- 2.30.2