Re: [PATCH v2] kunit: fix reference count leak in kfree_at_end

From: Brendan Higgins
Date: Tue Sep 28 2021 - 17:27:45 EST


On Thu, Sep 9, 2021 at 12:26 AM Xiyu Yang <xiyuyang19@xxxxxxxxxxxx> wrote:
>
> The reference counting issue happens in the normal path of
> kfree_at_end(). When kunit_alloc_and_get_resource() is invoked, the
> function forgets to handle the returned resource object, whose refcount
> increased inside, causing a refcount leak.
>
> Fix this issue by calling kunit_alloc_resource() instead of
> kunit_alloc_and_get_resource().
>
> Signed-off-by: Xiyu Yang <xiyuyang19@xxxxxxxxxxxx>
> Signed-off-by: Xin Tan <tanxin.ctf@xxxxxxxxx>

Reviewed-by: Brendan Higgins <brendanhiggins@xxxxxxxxxx>

Thanks!