summaryrefslogtreecommitdiffstats
path: root/lib/kunit
diff options
context:
space:
mode:
authorRichard Fitzgerald <rf@opensource.cirrus.com>2023-10-30 10:47:46 +0000
committerShuah Khan <skhan@linuxfoundation.org>2023-12-18 13:21:14 -0700
commit15bf0000147ae9fc8fa4969025f71848fc558cba (patch)
tree32cf92d581b01c348be1c75860751f7834779f71 /lib/kunit
parent37f0d37ffce1d162bfaf7f426afca38f6fe15472 (diff)
downloadlinux-stable-15bf0000147ae9fc8fa4969025f71848fc558cba.tar.gz
linux-stable-15bf0000147ae9fc8fa4969025f71848fc558cba.tar.bz2
linux-stable-15bf0000147ae9fc8fa4969025f71848fc558cba.zip
kunit: string-stream: Allow ERR_PTR to be passed to string_stream_destroy()
Check the stream pointer passed to string_stream_destroy() for IS_ERR_OR_NULL() instead of only NULL. Whatever alloc_string_stream() returns should be safe to pass to string_stream_destroy(), and that will be an ERR_PTR. It's obviously good practise and generally helpful to also check for NULL pointers so that client cleanup code can call string_stream_destroy() unconditionally - which could include pointers that have never been set to anything and so are NULL. Signed-off-by: Richard Fitzgerald <rf@opensource.cirrus.com> Reviewed-by: Rae Moar <rmoar@google.com> Reviewed-by: David Gow <davidgow@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'lib/kunit')
-rw-r--r--lib/kunit/string-stream.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/kunit/string-stream.c b/lib/kunit/string-stream.c
index a6f3616c2048..54f4fdcbfac8 100644
--- a/lib/kunit/string-stream.c
+++ b/lib/kunit/string-stream.c
@@ -173,7 +173,7 @@ void string_stream_destroy(struct string_stream *stream)
{
KUNIT_STATIC_STUB_REDIRECT(string_stream_destroy, stream);
- if (!stream)
+ if (IS_ERR_OR_NULL(stream))
return;
string_stream_clear(stream);