提交 84cc257e 编写于 作者: Y YoungJun.park 提交者: Greg Kroah-Hartman

kunit: alloc_string_stream_fragment error handling bug fix

[ Upstream commit 93ef8305 ]

When it fails to allocate fragment, it does not free and return error.
And check the pointer inappropriately.

Fixed merge conflicts with
commit 61888776 ("kunit: update NULL vs IS_ERR() tests")
Shuah Khan <skhan@linuxfoundation.org>
Signed-off-by: NYoungJun.park <her0gyugyu@gmail.com>
Reviewed-by: NDavid Gow <davidgow@google.com>
Signed-off-by: NShuah Khan <skhan@linuxfoundation.org>
Signed-off-by: NSasha Levin <sashal@kernel.org>
上级 8b2de521
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册