[PATCH] kunit: Fix wrong parameter to kunit_deactivate_static_stub()

3 views
Skip to first unread message

Tzung-Bi Shih

unread,
May 20, 2025, 4:21:06 AM5/20/25
to brendan...@linux.dev, davi...@google.com, rm...@google.com, linux-k...@vger.kernel.org, kuni...@googlegroups.com, tzu...@kernel.org
kunit_deactivate_static_stub() accepts real_fn_addr instead of
replacement_addr. In the case, it always passes NULL to
kunit_deactivate_static_stub().

Fix it.

Fixes: e047c5eaa763 ("kunit: Expose 'static stub' API to redirect functions")
Signed-off-by: Tzung-Bi Shih <tzu...@kernel.org>
---
lib/kunit/static_stub.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/kunit/static_stub.c b/lib/kunit/static_stub.c
index 92b2cccd5e76..484fd85251b4 100644
--- a/lib/kunit/static_stub.c
+++ b/lib/kunit/static_stub.c
@@ -96,7 +96,7 @@ void __kunit_activate_static_stub(struct kunit *test,

/* If the replacement address is NULL, deactivate the stub. */
if (!replacement_addr) {
- kunit_deactivate_static_stub(test, replacement_addr);
+ kunit_deactivate_static_stub(test, real_fn_addr);
return;
}

--
2.49.0.1101.gccaa498523-goog

David Gow

unread,
May 21, 2025, 3:44:20 AM5/21/25
to Tzung-Bi Shih, brendan...@linux.dev, rm...@google.com, linux-k...@vger.kernel.org, kuni...@googlegroups.com
On Tue, 20 May 2025 at 16:21, Tzung-Bi Shih <tzu...@kernel.org> wrote:
>
> kunit_deactivate_static_stub() accepts real_fn_addr instead of
> replacement_addr. In the case, it always passes NULL to
> kunit_deactivate_static_stub().
>
> Fix it.
>
> Fixes: e047c5eaa763 ("kunit: Expose 'static stub' API to redirect functions")
> Signed-off-by: Tzung-Bi Shih <tzu...@kernel.org>
> ---

Nice catch! I guess no-one's ever tried to pass NULL to deactivate the stub!

(Maybe we should add a test for this somewhere?)

Reviewed-by: David Gow <davi...@google.com>

Cheers,
-- David

Tzung-Bi Shih

unread,
May 22, 2025, 1:54:07 AM5/22/25
to David Gow, brendan...@linux.dev, rm...@google.com, linux-k...@vger.kernel.org, kuni...@googlegroups.com
On Wed, May 21, 2025 at 03:44:04PM +0800, David Gow wrote:
> On Tue, 20 May 2025 at 16:21, Tzung-Bi Shih <tzu...@kernel.org> wrote:
> >
> > kunit_deactivate_static_stub() accepts real_fn_addr instead of
> > replacement_addr. In the case, it always passes NULL to
> > kunit_deactivate_static_stub().
> >
> > Fix it.
> >
> > Fixes: e047c5eaa763 ("kunit: Expose 'static stub' API to redirect functions")
> > Signed-off-by: Tzung-Bi Shih <tzu...@kernel.org>
> > ---
>
> Nice catch! I guess no-one's ever tried to pass NULL to deactivate the stub!
>
> (Maybe we should add a test for this somewhere?)

Added a test for this,
https://lore.kernel.org/linux-kselftest/20250522054912.2...@kernel.org/T/#u
Reply all
Reply to author
Forward
0 new messages