Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3048125ybt; Mon, 29 Jun 2020 13:54:20 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwy+ItX+sq6A62aRZibUV85BqhvQyjx/3crw23akFrxY/WdfQyxCrnjItZFXfUEajOzzGV X-Received: by 2002:a50:d513:: with SMTP id u19mr18974560edi.241.1593464060687; Mon, 29 Jun 2020 13:54:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593464060; cv=none; d=google.com; s=arc-20160816; b=Jx0MqmcrWZjwrZkrFqe5TJNRBz8ZCFx705CEDXfgasbM5DVeTsrDkbj+r+uml8VEe/ EkwdJA4zixeT1Q4Sl1OAp48eExcgT+hIURbBSYJ8fAJZoHElmc81oqvuwj3dTMfCz+sH ycIJc0MLUnnE+m/Mj8I9Bsf5t8Fk+u/2qKejgTRoSYcvmW/RmPgGz5LP6uh+5MGPpSp5 D96QD+JAuje8ELAXVTqqDojBI1dlINcfLXrvuE0zpjwHgvARppnqN9BBhPSd7sGD0WKB fEXSc5g+ydb+ZIZW6293ILE5HcOt6DnOsb7+62xi+h4A+FdO8g81i8NIiIbmd7OYtskW uh7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=R9iN1s0rURejGgnL8BFjMhv7ALGwhdrXDovjWU0Q0qM=; b=dC0AUZllieVIH5LDHzmg2aI7INK5iGDPValiBoXsgsQz0AEfcPNqAcqNzKfD3XTYov hwF59CW8878sEXKb/8QWDBhrxFTIeKCOmNWkwLeIdPq/wVMMOHEUIZT+iaHNsfDfG5Wa DZvfv40e6P58l7miGfegnMSjIGuu+5s6W+qTrLVaWxvv6PlkPZHyt16s3kNYTF2Ug09s v0yFvuvfb5vCgUC1Zg/V7xwIqoYEiyrVsHJEmcA3L+sneac+RfN6jM22wf7wyuTsvh4M wQUoXLPIqAO7JkP8gPR1YcEznPtEoGECgwcQtJOHbJ79kNEl9maJl1Ec/ssO4IUP8lAh 3gBA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w16si355328ejq.299.2020.06.29.13.53.58; Mon, 29 Jun 2020 13:54:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387843AbgF2Uu5 (ORCPT + 99 others); Mon, 29 Jun 2020 16:50:57 -0400 Received: from relay10.mail.gandi.net ([217.70.178.230]:42333 "EHLO relay10.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387763AbgF2Uuu (ORCPT ); Mon, 29 Jun 2020 16:50:50 -0400 Received: from localhost.localdomain (unknown [176.88.144.104]) (Authenticated sender: cengiz@kernel.wtf) by relay10.mail.gandi.net (Postfix) with ESMTPSA id 8516C24000E; Mon, 29 Jun 2020 20:50:45 +0000 (UTC) From: Cengiz Can To: daniel.thompson@linaro.org Cc: andriy.shevchenko@linux.intel.com, cengiz@kernel.wtf, dianders@chromium.org, jason.wessel@windriver.com, kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org, pmladek@suse.com, sumit.garg@linaro.org Subject: [PATCH v2] kdb: remove unnecessary null check of dbg_io_ops Date: Mon, 29 Jun 2020 23:50:13 +0300 Message-Id: <20200629205012.3263-1-cengiz@kernel.wtf> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200629153756.cxg74nec3repa4lu@holly.lan> References: <20200629153756.cxg74nec3repa4lu@holly.lan> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org `kdb_msg_write` operates on a global `struct kgdb_io *` called `dbg_io_ops`. It's initialized in `debug_core.c` and checked throughout the debug flow. There's a null check in `kdb_msg_write` which triggers static analyzers and gives the (almost entirely wrong) impression that it can be null. Coverity scanner caught this as CID 1465042. I have removed the unnecessary null check and eliminated false-positive forward null dereference warning. Signed-off-by: Cengiz Can --- kernel/debug/kdb/kdb_io.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c index 683a799618ad..4ac59a4fbeec 100644 --- a/kernel/debug/kdb/kdb_io.c +++ b/kernel/debug/kdb/kdb_io.c @@ -549,14 +549,12 @@ static void kdb_msg_write(const char *msg, int msg_len) if (msg_len == 0) return; - if (dbg_io_ops) { - const char *cp = msg; - int len = msg_len; + const char *cp = msg; + int len = msg_len; - while (len--) { - dbg_io_ops->write_char(*cp); - cp++; - } + while (len--) { + dbg_io_ops->write_char(*cp); + cp++; } for_each_console(c) { -- 2.27.0