Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3398012ybt; Tue, 30 Jun 2020 01:32:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyDOtMnO66MvmGH4Z2Q1UweK37hKujzJNvffWwk/0jwJWGaELvFw6rPThMPsw5vKkt16hxi X-Received: by 2002:a17:906:c14f:: with SMTP id dp15mr17359909ejc.454.1593505923563; Tue, 30 Jun 2020 01:32:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593505923; cv=none; d=google.com; s=arc-20160816; b=nAFnawe13keaJ9rNop8mt4U4KTaZ5V8C/v7MWRDKwNU6thI0Bnky5WfvLMai6REkNB e0kdHSamfVVQuM50y/so1lV+v1iF/26TCjUV4VVbu7T/fOiTeJK10Kgnz8/3aTQGfnOL PRPigBGivP3KxFwLzdAQIsB5RPsxmMiiGvvqHMRJC8x2ut+zsoOuafE+YV21F7vzRkCU EUERDbGuse+7TSuwrP7GZV7ev3pN8CRmrwxXlsp6sPbNRDsia2+UU0ntpIHIgxbxbacK Yl1bAr6oM4dhH7rAcHzZlkFIFjkoAZ3iETUPw+/a9z6Z+guI9qFPl86AZxAYZKKFOyuL DXzw== 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=VATVENXYFj5EpWjzcjKDdDxtrXlKTZOFJfD8vL+9HIs=; b=Wqbcsw9gU5HOonB87cSjvoHit4pKaF3SyrErx2r2eHAmOSl6udhZHMdURmm5WlXkZR lcAZc18rgGEsO/5W0LFEvsrefC71dWPi/5fTAVOl1E1gzG9gLdoa5GAE7k97/AOxWNFs MM+nxPwyj0IeBNR9oxipSYpPSOSMlJ02tHueMfQhrLp/dW+wM+vAJOM7kV9+6Gmk1rzH VCdB+/N0hjIRCpUkw0xs5lF7l46PGBSHytKmD2iEJ4kyxpafEy/fLf0RvyGAoRtPdOQe u6pnR/iAO/E/A5Ei1c5maaMW0GusyRRxWqHvwB03P2kcvszbIv/u632w2vUkPOfAPFk+ l+/A== 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 dr12si1591486ejc.352.2020.06.30.01.31.40; Tue, 30 Jun 2020 01:32:03 -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 S1731507AbgF3IaO (ORCPT + 99 others); Tue, 30 Jun 2020 04:30:14 -0400 Received: from relay10.mail.gandi.net ([217.70.178.230]:44315 "EHLO relay10.mail.gandi.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727059AbgF3IaO (ORCPT ); Tue, 30 Jun 2020 04:30:14 -0400 Received: from localhost.localdomain (unknown [176.88.144.104]) (Authenticated sender: cengiz@kernel.wtf) by relay10.mail.gandi.net (Postfix) with ESMTPSA id DCB5D24001E; Tue, 30 Jun 2020 08:30:02 +0000 (UTC) From: Cengiz Can To: sumit.garg@linaro.org Cc: andriy.shevchenko@linux.intel.com, cengiz@kernel.wtf, daniel.thompson@linaro.org, dianders@chromium.org, jason.wessel@windriver.com, kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org, pmladek@suse.com Subject: [PATCH v3] kdb: remove unnecessary null check of dbg_io_ops Date: Tue, 30 Jun 2020 11:29:23 +0300 Message-Id: <20200630082922.28672-1-cengiz@kernel.wtf> X-Mailer: git-send-email 2.27.0 In-Reply-To: References: 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 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c index 683a799618ad..81783ecaec58 100644 --- a/kernel/debug/kdb/kdb_io.c +++ b/kernel/debug/kdb/kdb_io.c @@ -545,18 +545,18 @@ static int kdb_search_string(char *searched, char *searchfor) static void kdb_msg_write(const char *msg, int msg_len) { struct console *c; + const char *cp; + int len; if (msg_len == 0) return; - if (dbg_io_ops) { - const char *cp = msg; - int len = msg_len; + cp = msg; + 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