Skip to contentSkip to conversation

kunit: Fix wrong parameter to kunit_deactivate_static_stub()

PATCH In review Tzung-Bi Shih 2 participants 3 messages May 20, 2025 – May 22, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kunit: Fix wrong parameter to kunit_deactivate_static_stub()

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")
---
 lib/kunit/static_stub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/kunit/static_stub.c +1 -1
index 92b2cccd5e76..484fd85251b4 100644
@@ -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;
 	}
 
Signature · 1 line
2.49.0.1101.gccaa498523-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Tzung-Bi Shih

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")

---

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?)

Cheers,
-- David

Quoted 19 lines
 lib/kunit/static_stub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/kunit/static_stub.c +1 -2
index 92b2cccd5e76..484fd85251b4 100644
@@ -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

#2 lore raw
Quoted 8 lines · David Gow
Quoted 7 lines · Tzung-Bi Shih

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.

Quoted 7 lines
Quoted 3 lines
Fixes e047c5eaa763 ("kunit: Expose 'static stub' API to redirect functions")

---

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/[email protected]/T/#u