mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] kunit: Fix NULL-dereference in kunit_init_suite() if suite->log is NULL
@ 2023-12-18 15:17 Richard Fitzgerald
  2023-12-19 21:03 ` Rae Moar
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Richard Fitzgerald @ 2023-12-18 15:17 UTC (permalink / raw)
  To: brendan.higgins, davidgow, rmoar
  Cc: linux-kselftest, kunit-dev, linux-kernel, patches, Richard Fitzgerald

suite->log must be checked for NULL before passing it to
string_stream_clear(). This was done in kunit_init_test() but was missing
from kunit_init_suite().

Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
Fixes: 6d696c4695c5 ("kunit: add ability to run tests after boot using debugfs")
---
 lib/kunit/test.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/kunit/test.c b/lib/kunit/test.c
index e803d998e855..ea7f0913e55a 100644
--- a/lib/kunit/test.c
+++ b/lib/kunit/test.c
@@ -658,7 +658,9 @@ static void kunit_init_suite(struct kunit_suite *suite)
 	kunit_debugfs_create_suite(suite);
 	suite->status_comment[0] = '\0';
 	suite->suite_init_err = 0;
-	string_stream_clear(suite->log);
+
+	if (suite->log)
+		string_stream_clear(suite->log);
 }
 
 bool kunit_enabled(void)
-- 
2.30.2


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kunit: Fix NULL-dereference in kunit_init_suite() if suite->log is NULL
  2023-12-18 15:17 [PATCH] kunit: Fix NULL-dereference in kunit_init_suite() if suite->log is NULL Richard Fitzgerald
@ 2023-12-19 21:03 ` Rae Moar
  2023-12-22  8:38 ` David Gow
  2023-12-30  7:20 ` Muhammad Usama Anjum
  2 siblings, 0 replies; 4+ messages in thread
From: Rae Moar @ 2023-12-19 21:03 UTC (permalink / raw)
  To: Richard Fitzgerald
  Cc: brendan.higgins, davidgow, linux-kselftest, kunit-dev,
	linux-kernel, patches

On Mon, Dec 18, 2023 at 10:17 AM Richard Fitzgerald
<rf@opensource.cirrus.com> wrote:
>
> suite->log must be checked for NULL before passing it to
> string_stream_clear(). This was done in kunit_init_test() but was missing
> from kunit_init_suite().
>
> Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
> Fixes: 6d696c4695c5 ("kunit: add ability to run tests after boot using debugfs")

Hello!

This looks good! Thanks! Sorry I did not catch this earlier.

Reviewed-by: Rae Moar <rmoar@google.com>

-Rae

> ---
>  lib/kunit/test.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/lib/kunit/test.c b/lib/kunit/test.c
> index e803d998e855..ea7f0913e55a 100644
> --- a/lib/kunit/test.c
> +++ b/lib/kunit/test.c
> @@ -658,7 +658,9 @@ static void kunit_init_suite(struct kunit_suite *suite)
>         kunit_debugfs_create_suite(suite);
>         suite->status_comment[0] = '\0';
>         suite->suite_init_err = 0;
> -       string_stream_clear(suite->log);
> +
> +       if (suite->log)
> +               string_stream_clear(suite->log);
>  }
>
>  bool kunit_enabled(void)
> --
> 2.30.2
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kunit: Fix NULL-dereference in kunit_init_suite() if suite->log is NULL
  2023-12-18 15:17 [PATCH] kunit: Fix NULL-dereference in kunit_init_suite() if suite->log is NULL Richard Fitzgerald
  2023-12-19 21:03 ` Rae Moar
@ 2023-12-22  8:38 ` David Gow
  2023-12-30  7:20 ` Muhammad Usama Anjum
  2 siblings, 0 replies; 4+ messages in thread
From: David Gow @ 2023-12-22  8:38 UTC (permalink / raw)
  To: Richard Fitzgerald
  Cc: brendan.higgins, rmoar, linux-kselftest, kunit-dev, linux-kernel,
	patches

[-- Attachment #1: Type: text/plain, Size: 1066 bytes --]

On Mon, 18 Dec 2023 at 23:17, Richard Fitzgerald
<rf@opensource.cirrus.com> wrote:
>
> suite->log must be checked for NULL before passing it to
> string_stream_clear(). This was done in kunit_init_test() but was missing
> from kunit_init_suite().
>
> Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
> Fixes: 6d696c4695c5 ("kunit: add ability to run tests after boot using debugfs")
> ---

Acked-by: David Gow <davidgow@google.com>

Cheers,
-- David


>  lib/kunit/test.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/lib/kunit/test.c b/lib/kunit/test.c
> index e803d998e855..ea7f0913e55a 100644
> --- a/lib/kunit/test.c
> +++ b/lib/kunit/test.c
> @@ -658,7 +658,9 @@ static void kunit_init_suite(struct kunit_suite *suite)
>         kunit_debugfs_create_suite(suite);
>         suite->status_comment[0] = '\0';
>         suite->suite_init_err = 0;
> -       string_stream_clear(suite->log);
> +
> +       if (suite->log)
> +               string_stream_clear(suite->log);
>  }
>
>  bool kunit_enabled(void)
> --
> 2.30.2
>

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4003 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] kunit: Fix NULL-dereference in kunit_init_suite() if suite->log is NULL
  2023-12-18 15:17 [PATCH] kunit: Fix NULL-dereference in kunit_init_suite() if suite->log is NULL Richard Fitzgerald
  2023-12-19 21:03 ` Rae Moar
  2023-12-22  8:38 ` David Gow
@ 2023-12-30  7:20 ` Muhammad Usama Anjum
  2 siblings, 0 replies; 4+ messages in thread
From: Muhammad Usama Anjum @ 2023-12-30  7:20 UTC (permalink / raw)
  To: Richard Fitzgerald, brendan.higgins, davidgow, rmoar
  Cc: Muhammad Usama Anjum, linux-kselftest, kunit-dev, linux-kernel, patches

On 12/18/23 8:17 PM, Richard Fitzgerald wrote:
> suite->log must be checked for NULL before passing it to
> string_stream_clear(). This was done in kunit_init_test() but was missing
> from kunit_init_suite().
> 
> Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com>
> Fixes: 6d696c4695c5 ("kunit: add ability to run tests after boot using debugfs")
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>

> ---
>  lib/kunit/test.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/lib/kunit/test.c b/lib/kunit/test.c
> index e803d998e855..ea7f0913e55a 100644
> --- a/lib/kunit/test.c
> +++ b/lib/kunit/test.c
> @@ -658,7 +658,9 @@ static void kunit_init_suite(struct kunit_suite *suite)
>  	kunit_debugfs_create_suite(suite);
>  	suite->status_comment[0] = '\0';
>  	suite->suite_init_err = 0;
> -	string_stream_clear(suite->log);
> +
> +	if (suite->log)
> +		string_stream_clear(suite->log);
>  }
>  
>  bool kunit_enabled(void)

-- 
BR,
Muhammad Usama Anjum

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-12-30  7:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-18 15:17 [PATCH] kunit: Fix NULL-dereference in kunit_init_suite() if suite->log is NULL Richard Fitzgerald
2023-12-19 21:03 ` Rae Moar
2023-12-22  8:38 ` David Gow
2023-12-30  7:20 ` Muhammad Usama Anjum

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®