From: YoungJun.park Date: Fri, 28 Oct 2022 14:42:41 +0000 (-0700) Subject: kunit: alloc_string_stream_fragment error handling bug fix X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=84cc257e1888862e3018db2c402b44b8915c1eb1;p=users%2Fjedix%2Flinux-maple.git kunit: alloc_string_stream_fragment error handling bug fix [ Upstream commit 93ef83050e597634d2c7dc838a28caf5137b9404 ] 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 Signed-off-by: YoungJun.park Reviewed-by: David Gow Signed-off-by: Shuah Khan Signed-off-by: Sasha Levin --- diff --git a/lib/kunit/string-stream.c b/lib/kunit/string-stream.c index a608746020a9..7aeabe1a3dc5 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; }