From: Colin King <colin.king@canonical.com> To: Brendan Higgins <brendanhiggins@google.com>, Frank Rowand <frank.rowand@sony.com>, Shuah Khan <skhan@linuxfoundation.org>, Alan Maguire <alan.maguire@oracle.com>, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] kunit: fix dereference of suite before it has been null checked Date: Thu, 2 Apr 2020 16:03:14 +0100 [thread overview] Message-ID: <20200402150314.568044-1-colin.king@canonical.com> (raw) From: Colin Ian King <colin.king@canonical.com> Currently pointer 'suite' is dereferenced when variable success is being initialized before the pointer is null checked. Fix this by only dereferencing suite after is has been null checked. Addresses-Coverity: ("Dereference before null check") Fixes: e2219db280e3 ("kunit: add debugfs /sys/kernel/debug/kunit/<suite>/results display") Signed-off-by: Colin Ian King <colin.king@canonical.com> --- lib/kunit/debugfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/kunit/debugfs.c b/lib/kunit/debugfs.c index 9214c493d8b7..05547642f37c 100644 --- a/lib/kunit/debugfs.c +++ b/lib/kunit/debugfs.c @@ -52,12 +52,13 @@ static void debugfs_print_result(struct seq_file *seq, static int debugfs_print_results(struct seq_file *seq, void *v) { struct kunit_suite *suite = (struct kunit_suite *)seq->private; - bool success = kunit_suite_has_succeeded(suite); + bool success; struct kunit_case *test_case; if (!suite || !suite->log) return 0; + success = kunit_suite_has_succeeded(suite); seq_printf(seq, "%s", suite->log); kunit_suite_for_each_test_case(suite, test_case) -- 2.25.1
WARNING: multiple messages have this Message-ID (diff)
From: Colin King <colin.king@canonical.com> To: Brendan Higgins <brendanhiggins@google.com>, Frank Rowand <frank.rowand@sony.com>, Shuah Khan <skhan@linuxfoundation.org>, Alan Maguire <alan.maguire@oracle.com>, linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH][next] kunit: fix dereference of suite before it has been null checked Date: Thu, 02 Apr 2020 15:03:14 +0000 [thread overview] Message-ID: <20200402150314.568044-1-colin.king@canonical.com> (raw) From: Colin Ian King <colin.king@canonical.com> Currently pointer 'suite' is dereferenced when variable success is being initialized before the pointer is null checked. Fix this by only dereferencing suite after is has been null checked. Addresses-Coverity: ("Dereference before null check") Fixes: e2219db280e3 ("kunit: add debugfs /sys/kernel/debug/kunit/<suite>/results display") Signed-off-by: Colin Ian King <colin.king@canonical.com> --- lib/kunit/debugfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/kunit/debugfs.c b/lib/kunit/debugfs.c index 9214c493d8b7..05547642f37c 100644 --- a/lib/kunit/debugfs.c +++ b/lib/kunit/debugfs.c @@ -52,12 +52,13 @@ static void debugfs_print_result(struct seq_file *seq, static int debugfs_print_results(struct seq_file *seq, void *v) { struct kunit_suite *suite = (struct kunit_suite *)seq->private; - bool success = kunit_suite_has_succeeded(suite); + bool success; struct kunit_case *test_case; if (!suite || !suite->log) return 0; + success = kunit_suite_has_succeeded(suite); seq_printf(seq, "%s", suite->log); kunit_suite_for_each_test_case(suite, test_case) -- 2.25.1
next reply other threads:[~2020-04-02 15:04 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-04-02 15:03 Colin King [this message] 2020-04-02 15:03 ` [PATCH][next] kunit: fix dereference of suite before it has been null checked Colin King 2020-04-02 15:24 ` Alan Maguire 2020-04-02 15:24 ` Alan Maguire
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20200402150314.568044-1-colin.king@canonical.com \ --to=colin.king@canonical.com \ --cc=alan.maguire@oracle.com \ --cc=brendanhiggins@google.com \ --cc=frank.rowand@sony.com \ --cc=kernel-janitors@vger.kernel.org \ --cc=kunit-dev@googlegroups.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-kselftest@vger.kernel.org \ --cc=skhan@linuxfoundation.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.