Skip to content

Commit 93ef830

Browse files
youngjun-89shuahkh
authored andcommitted
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 6188877 ("kunit: update NULL vs IS_ERR() tests") Shuah Khan <[email protected]> Signed-off-by: YoungJun.park <[email protected]> Reviewed-by: David Gow <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent 1b929c0 commit 93ef830

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/kunit/string-stream.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ static struct string_stream_fragment *alloc_string_stream_fragment(
2323
return ERR_PTR(-ENOMEM);
2424

2525
frag->fragment = kunit_kmalloc(test, len, gfp);
26-
if (!frag->fragment)
26+
if (!frag->fragment) {
27+
kunit_kfree(test, frag);
2728
return ERR_PTR(-ENOMEM);
29+
}
2830

2931
return frag;
3032
}

0 commit comments

Comments
 (0)