summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorYoungJun.park <her0gyugyu@gmail.com>2022-10-28 07:42:41 -0700
committerShuah Khan <skhan@linuxfoundation.org>2022-12-26 16:01:36 -0700
commit93ef83050e597634d2c7dc838a28caf5137b9404 (patch)
tree7984fc7622b05de2dbec6af321d83c51f11525e5 /lib
parent1b929c02afd37871d5afb9d498426f83432e71c2 (diff)
downloadlinux-93ef83050e597634d2c7dc838a28caf5137b9404.tar.gz
linux-93ef83050e597634d2c7dc838a28caf5137b9404.tar.bz2
linux-93ef83050e597634d2c7dc838a28caf5137b9404.zip
kunit: alloc_string_stream_fragment error handling bug fix
When it fails to allocate fragment, it does not free and return error. And check the pointer inappropriately. Fixed merge conflicts with commit 618887768bb7 ("kunit: update NULL vs IS_ERR() tests") Shuah Khan <skhan@linuxfoundation.org> Signed-off-by: YoungJun.park <her0gyugyu@gmail.com> Reviewed-by: David Gow <davidgow@google.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/kunit/string-stream.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/kunit/string-stream.c b/lib/kunit/string-stream.c
index f5f51166d8c2..cc32743c1171 100644
--- a/lib/kunit/string-stream.c
+++ b/lib/kunit/string-stream.c
@@ -23,8 +23,10 @@ static struct string_stream_fragment *alloc_string_stream_fragment(
return ERR_PTR(-ENOMEM);
frag->fragment = kunit_kmalloc(test, len, gfp);
- if (!frag->fragment)
+ if (!frag->fragment) {
+ kunit_kfree(test, frag);
return ERR_PTR(-ENOMEM);
+ }
return frag;
}