Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3413388rdh; Thu, 28 Sep 2023 10:49:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEh1EbuvC058qVghGrStY4vzmL9U42Oz/ZgccbLKL3RrVTnRef00ZjirZVvDb4hNQG4UIbY X-Received: by 2002:a05:6871:723:b0:1dd:7f3a:b8ee with SMTP id f35-20020a056871072300b001dd7f3ab8eemr2310837oap.20.1695923364591; Thu, 28 Sep 2023 10:49:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695923364; cv=none; d=google.com; s=arc-20160816; b=o8DnZyxe9eEhpxI5AqreduPUifCjZEzNVROm3FFU+PmhJG0zx8qb4YviXf7Clbzpdo LmprmNfysgGYbBd7XY9uGYtrLC6vdgNFm9lt5WGNPhJCzRqVGsdcBfVE3O1kfVmgge4f NV6IMyEbWLYfRrTtBm/x5xTkZSIrmixSsKdUZOWwHnKVmYmzn+OjgzKmRC5uDrlLW70U xlpolTnQQgnfMCV7E0psVJJPTEd0Edo0zl1w1vSqKXeu+fB4hdmhYJM4FzavG1JSdatF f4cYRGCGHx+XS5dXxWMOjuUsxQ7J9BFKkjxKxAvAaniBYOlt7YiKdCl51GcsCkgVv88B oChQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=ptuXmZ2hqF+4cAMHCMtuZ+jtvOIi1tvA4FTQu+eJeZY=; fh=zFy42mhpE2u4xFwte26xQa/ZLoka/uZdP9ObmF0xxgQ=; b=vGpr3KVQ0Lc+btA1LN/EbQcHolF73wUFSsl7LUWgsr0491cHI2yP71CZKLXjNnQLQR UAmxDVx+fAi96pn4b89s6lyoonHicqkFM12CdAcVvksVYFPcLSGqCMctBCKBsfX/Dvi6 7cOk4+uzheFiNZYAz6OcMaQdEi+dA2DiFa4pZNMxUXVkyuvGdmNySothCbqJj22qrQlS LeRp60+GSu/QVOViUI3OwQ9JKqSlF3ufVZu/dNJ32j2nEgLXz/byEv2McPYYNYvScpWL LMJIztQywpP11hNGs0blk3Udpc1JYzmd1Ps/Qom5BYJ5jAzaYZJDPKN3eB7VQbhOjcE5 W+9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=bnLMoFBw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id z16-20020a656650000000b00584b6af3b9fsi7665240pgv.524.2023.09.28.10.49.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 10:49:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=bnLMoFBw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 5C733829537E; Thu, 28 Sep 2023 04:37:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231843AbjI1Lhb (ORCPT + 99 others); Thu, 28 Sep 2023 07:37:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45166 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231167AbjI1Lha (ORCPT ); Thu, 28 Sep 2023 07:37:30 -0400 Received: from mx0b-001ae601.pphosted.com (mx0b-001ae601.pphosted.com [67.231.152.168]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 967009C; Thu, 28 Sep 2023 04:37:28 -0700 (PDT) Received: from pps.filterd (m0077474.ppops.net [127.0.0.1]) by mx0b-001ae601.pphosted.com (8.17.1.22/8.17.1.22) with ESMTP id 38SBT6HS003484; Thu, 28 Sep 2023 06:37:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding:content-type; s=PODMain02222019; bh=p tuXmZ2hqF+4cAMHCMtuZ+jtvOIi1tvA4FTQu+eJeZY=; b=bnLMoFBwLxlHwjnWP l7q8J5Jjd/tTfKE73iZf7of3UTgRPxdP2hnd+LghsV1MNnH4Uvxq2Koe2jhl/8aY rutC7Q8/puGKQG+8CqIFnEmaOJBV9V7w1jNyHPkdGQjRRwXSx+Dt3DQYAnK93sRk 2KmSwO0MI+lW7i3uj7BgZr8tV7nXk20+6y0nT6RET1c73MlpPWuPy0HBryRV0ULO 4zkAFQkv6xASDNJ1M0CSIZ0rpRJme7yCmDLw9PA07bXII6plhi+1cQyVTpbitd9z R3NKxmWgHPWG6bwChRz+6v57TcIVxOIW3z9qONk73m8BUED5jvN/QH1caOSGfpB9 ykE3g== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0b-001ae601.pphosted.com (PPS) with ESMTPS id 3t9veje087-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Sep 2023 06:37:23 -0500 (CDT) Received: from ediex01.ad.cirrus.com (198.61.84.80) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.37; Thu, 28 Sep 2023 12:37:21 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server id 15.2.1118.37 via Frontend Transport; Thu, 28 Sep 2023 12:37:21 +0100 Received: from edi-sw-dsktp-006.ad.cirrus.com (edi-sw-dsktp-006.ad.cirrus.com [198.90.251.13]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 255AB11AB; Thu, 28 Sep 2023 11:37:21 +0000 (UTC) From: Richard Fitzgerald To: , , CC: , , , , "Richard Fitzgerald" , Dan Carpenter Subject: [PATCH] kunit: debugfs: Fix unchecked dereference in debugfs_print_results() Date: Thu, 28 Sep 2023 12:37:21 +0100 Message-ID: <20230928113721.3867117-1-rf@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: 5pMYG62xJDFvXrySNZzRtJ72E7kGlvej X-Proofpoint-ORIG-GUID: 5pMYG62xJDFvXrySNZzRtJ72E7kGlvej X-Proofpoint-Spam-Reason: safe X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 28 Sep 2023 04:37:41 -0700 (PDT) Move the call to kunit_suite_has_succeeded() after the check that the kunit_suite pointer is valid. This was found by smatch: lib/kunit/debugfs.c:66 debugfs_print_results() warn: variable dereferenced before check 'suite' (see line 63) Signed-off-by: Richard Fitzgerald Reported-by: Dan Carpenter Fixes: 38289a26e1b8 ("kunit: fix debugfs code to use enum kunit_status, not bool") --- lib/kunit/debugfs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/kunit/debugfs.c b/lib/kunit/debugfs.c index 9d167adfa746..382706dfb47d 100644 --- a/lib/kunit/debugfs.c +++ b/lib/kunit/debugfs.c @@ -60,12 +60,14 @@ static void debugfs_print_result(struct seq_file *seq, struct string_stream *log static int debugfs_print_results(struct seq_file *seq, void *v) { struct kunit_suite *suite = (struct kunit_suite *)seq->private; - enum kunit_status success = kunit_suite_has_succeeded(suite); + enum kunit_status success; struct kunit_case *test_case; if (!suite) return 0; + success = kunit_suite_has_succeeded(suite); + /* Print KTAP header so the debugfs log can be parsed as valid KTAP. */ seq_puts(seq, "KTAP version 1\n"); seq_puts(seq, "1..1\n"); -- 2.30.2