Skip to content

Commit

Permalink
kunit: alloc_string_stream_fragment error handling bug fix
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
youngjun-89 authored and shuahkh committed Dec 26, 2022
1 parent 1b929c0 commit 93ef830
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/kunit/string-stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 93ef830

Please sign in to comment.