Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3519523ybt; Tue, 30 Jun 2020 05:04:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBwMS/ez5AlkgeEW+h3eYULb2p2N90l7VMURfMs6sNQZAvM+aavJ88tJBpqGS209XoFn3J X-Received: by 2002:a17:906:2bc2:: with SMTP id n2mr17421052ejg.115.1593518666323; Tue, 30 Jun 2020 05:04:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593518666; cv=none; d=google.com; s=arc-20160816; b=oRdGY3hxRvE8W2lplEti7q3X4gFWZQC6RT/XTuOLIi92KOfWEqcmRbut/j8Qh8Xv70 dNYWYPZZhDk8bZA/zuzFmefpDo03p9WpXuz0AdIoaQjNmk7DbOLsVqQU8dNVPlOih3uE C66W+vUtiL+E6MxMMi4Atu71VGnc4kx2sBjw6UBHXr4O/up0wMxiiPWXLPZINV118uwL OoMNnX55R3jhlKLufyqmVpct5a/o/5edVyv2q3JiFlC3yf3UfAnK/wqm3dmKGlhoqKEY JSDMDjTYOzgRR6jQvuREuRS9zr4dPvLluThsw3cs43f72UkVTe/CFkemwoNAekAMmc7h 7XiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=ZwFfXOGz4fxYZqVjks/MQV6KVpu2SdXqlr5+gsasvuE=; b=w4Nvvs3wOPc5sYYGrpGy72WwYC1u30jY4UeeA5FnRl6GE6BQpqdXmjprY0uE1vEX+T AfInmuU5MXtc2QP4Iy6RPP8Y1qyhjrsgI/ChbRAMFS6hxqKtTIC3mRUJHfxd3xT+sHjl MkbjSDofXTidJ0pBHQp0+I1eWmknuFDP/3+UbMJB42CoKbMTsbU6u8IUcGQV5Z2x0dOJ M2iJ1s8SYKAswse3Z/srTq3xa3oKAFcfLNfsdIA0nS86R5eOOROhRKhY4qbcmqdJLgzs UecNgkpr+3qEwKgxz2zDdo3/Hre0g90Gj9fBHDeF0yFuEs18tghZPXKLzVQTLNpyN6m1 nGNQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="d2Z/LJOr"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k13si1651805ejq.296.2020.06.30.05.04.03; Tue, 30 Jun 2020 05:04:26 -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; dkim=pass header.i=@linaro.org header.s=google header.b="d2Z/LJOr"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732998AbgF3Lgq (ORCPT + 99 others); Tue, 30 Jun 2020 07:36:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727108AbgF3Lgp (ORCPT ); Tue, 30 Jun 2020 07:36:45 -0400 Received: from mail-lf1-x144.google.com (mail-lf1-x144.google.com [IPv6:2a00:1450:4864:20::144]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8A04C061755 for ; Tue, 30 Jun 2020 04:36:44 -0700 (PDT) Received: by mail-lf1-x144.google.com with SMTP id c21so11139184lfb.3 for ; Tue, 30 Jun 2020 04:36:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZwFfXOGz4fxYZqVjks/MQV6KVpu2SdXqlr5+gsasvuE=; b=d2Z/LJOrxI2sK/tnaStkPJbMfShNAs6iVqT+bRYw0LM4swNXBIn2gO3o+QA/oDFXXu 1H7pynjzt1f7s6oQ7MJ7ffa/nyEWclXo/+z/QgQEAqK5MR9ISJaKinJpScZQLM1BUqtD oItWSrmUk6BAJEfVY5q8jDk1QbUIIVylOrDDym0HHRr/4uskhZMJqxMveoFBUO7CnKi6 tgFnwrDpCuFVoQCdrq5oOmrBbjcGyRMaKhWnlsaNWLba76yPtqZegF2oogYgqqsJ54Gb jNdCJGUm0ietNh0RWrauTNTxTIjpkx0LttlMXfKYPPLIk6gbIexfbYcDPL0TbzOcvABn n1UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZwFfXOGz4fxYZqVjks/MQV6KVpu2SdXqlr5+gsasvuE=; b=cvlMPGysdCxk1VSnsh1VgPyuVsWOxXoy0Hy+Or9hrZpGu4FDQCs7X+1ywsgGLbN/13 nBG8SKfzyZyb57d1ndIZVJvCMUwWGVnOIXpvS43S67DXNHomN6n+xGgW2n6EwT9UlWMe MzbyUHtDGY2RBDQy0efd15sv4GxLrbbS2hcPR21IMsl3g/K9VO8YQkojc1h3vbfw/Mse H+x3AA13Xr7DLezxZJhO5v5rsTbgCJX3kwkd9ou4EgdXqDCrwjiHuAe2LGwetj8xpMNQ ldsSPQk4qoreC6K/ZX8thsBUpdHpHH6teSqxjiFZPmmKIHNg7fIsTtb03CvjRdZLI02t mNGQ== X-Gm-Message-State: AOAM531F6jg/7hv1UJL5f4Y+FRNOAnKEVnSyvxA2GknEW+F1gP48voia ct6U4FK/YZzZkRa1lqEclJB+Kot7GiLhZmKDaXC8swCyfH8J8Q== X-Received: by 2002:a19:cc93:: with SMTP id c141mr11746250lfg.15.1593517003341; Tue, 30 Jun 2020 04:36:43 -0700 (PDT) MIME-Version: 1.0 References: <20200630082922.28672-1-cengiz@kernel.wtf> In-Reply-To: <20200630082922.28672-1-cengiz@kernel.wtf> From: Sumit Garg Date: Tue, 30 Jun 2020 17:06:31 +0530 Message-ID: Subject: Re: [PATCH v3] kdb: remove unnecessary null check of dbg_io_ops To: Cengiz Can Cc: Andy Shevchenko , Daniel Thompson , Douglas Anderson , Jason Wessel , kgdb-bugreport@lists.sourceforge.net, Linux Kernel Mailing List , Petr Mladek Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 30 Jun 2020 at 14:00, Cengiz Can wrote: > > `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(-) > Reviewed-by: Sumit Garg > 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 >