From patchwork Mon Jul 17 19:46:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Ogness X-Patchwork-Id: 121581 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1322779vqt; Mon, 17 Jul 2023 13:14:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlHA6NZ782MC7+srckx53/TwyHnr1wWc1sNgl0zMSBGR/BVVZoICBMflJexEuFO0hQSPlXuE X-Received: by 2002:ac2:58d5:0:b0:4f9:6535:a56 with SMTP id u21-20020ac258d5000000b004f965350a56mr217409lfo.26.1689624857330; Mon, 17 Jul 2023 13:14:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689624857; cv=none; d=google.com; s=arc-20160816; b=sNk7fj/n5BKMDWbQdVRanXJNZB+htto71RKReW2Bb736g2ewoDcMdWwOZSw7VryG7Q I5M9jk6/iId9wJJZdK65XJOTV3R7VkvxkW4v0KweZmqbZ/eP3VIWCdrf5FdOpMsP5ryH E6pgThNBHy+Z12OfYN+c0sFWQ8uGeTkOqfXRKUrSIxw6cgkDP5JeHBL+9kAvcsP9Ho/5 3+k0yTn9gMmlDPTV3Y0S1SYiz7pfFSlSpOcqqxqJa3RACPpjsBcriJ6ARShRflpoenpZ qkB4ZZL3IAYenTXLZOXE5mSsxWy8qRuxxmEerWJQhZmMUydqEpFGB/3s7zt2Urc6s9AX jmOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:dkim-signature :dkim-signature:from; bh=xJlaA7aw7VfN9sYStH6KtmsbXY1A2Osy2reIpHftB/8=; fh=FmGDdgxgAqjzIwBffCEQi+NWFaUddSrn2FgJHvKhtP8=; b=oDhWlVT0ClpeVbOSRJF3QPPwePd/N5sxllGL8fWg4a/x7mIluAihqI3ondiqhspn/J eFGd3I/H++20hxcp4FMrKEGFOGJ0nOnarUuDgWIHwi8ebgLcytXJKFzDDgB7mGYMxazF OJBgF5u5LmzJrltKD/BARlUsMfYDM7AiQTAc5toUXX+H22GVKBARNAHJPboqR1L/0dqm L7JfaQJYdeGGq8HYx1MrgIm+nviij0x+HIwATk147rzR3WEXMUoUqf+5M0PftCbbsVTe 6WOrPE2rggEjddSr0cZ/EYSXkxPmbpHqoLVertWVRFFukvipxN7nL7mR2lb2WfdIwwCA IBmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=hLXqcX9T; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h26-20020aa7c61a000000b0051a3fb6c050si84768edq.187.2023.07.17.13.13.53; Mon, 17 Jul 2023 13:14:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=hLXqcX9T; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231648AbjGQTqT (ORCPT + 99 others); Mon, 17 Jul 2023 15:46:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229665AbjGQTqM (ORCPT ); Mon, 17 Jul 2023 15:46:12 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 02677129 for ; Mon, 17 Jul 2023 12:46:12 -0700 (PDT) From: John Ogness DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1689623170; 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=xJlaA7aw7VfN9sYStH6KtmsbXY1A2Osy2reIpHftB/8=; b=hLXqcX9TNwR0vfRhp+zeVqQ8N5qReqFQ0GcOwV5pqfcy0SanXa8hWsfU+muKGB0llivZee CaR2IrrEwJwNVSQHKBvSBf8Wyt8MQi4VY2oEk1BtjUQbCDqF5ZiWXmuQSvYJCt9AG8QtUD FmHRrSHhw+JYxMFz5fu5tSohEdrIvTDW28EowF5cLMSbxZwybP3hp3J8CWkXQMY0okus6+ Myr2hVS3HoQHhup5HvCOWsO/JdMkI0RO/l/9JGjUY+E4L21D71dJwWinrymK6qnyS7M6bS sMGHeH3rS9/GQEkgXqMMaQlRfBpdrGRI/sBKY6XobFp1+bGqEqmlR5sjsnUlIg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1689623170; 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=xJlaA7aw7VfN9sYStH6KtmsbXY1A2Osy2reIpHftB/8=; b=+bp4XZEFJTjresY54VEvYmJiPjGq31ehBWLMsXYtqk50RYYNVlBMTGYTf2CAsUW2/xaRAm xlEPZitTFrBbAuCw== To: Petr Mladek Cc: Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, Jason Wessel , Daniel Thompson , Douglas Anderson , Aaron Tomlin Subject: [PATCH printk v3 1/7] kdb: Do not assume write() callback available Date: Mon, 17 Jul 2023 21:52:01 +0206 Message-Id: <20230717194607.145135-2-john.ogness@linutronix.de> In-Reply-To: <20230717194607.145135-1-john.ogness@linutronix.de> References: <20230717194607.145135-1-john.ogness@linutronix.de> MIME-Version: 1.0 X-Spam-Status: No, score=-1.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,INVALID_DATE_TZ_ABSURD, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1771700074325227797 X-GMAIL-MSGID: 1771700074325227797 It is allowed for consoles to not provide a write() callback. For example ttynull does this. Check if a write() callback is available before using it. Signed-off-by: John Ogness Reviewed-by: Petr Mladek Reviewed-by: Douglas Anderson Reviewed-by: Daniel Thompson Acked-by: Daniel Thompson Reviewed-by: Sergey Senozhatsky --- kernel/debug/kdb/kdb_io.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c index 5c7e9ba7cd6b..e9139dfc1f0a 100644 --- a/kernel/debug/kdb/kdb_io.c +++ b/kernel/debug/kdb/kdb_io.c @@ -576,6 +576,8 @@ static void kdb_msg_write(const char *msg, int msg_len) continue; if (c == dbg_io_ops->cons) continue; + if (!c->write) + continue; /* * Set oops_in_progress to encourage the console drivers to * disregard their internal spin locks: in the current calling