One of the sysctl tests registers a valid sysctl table. This operation is expected to succeed. However, it does not unregister the table after executing the test. If the code is built as module and the module is unloaded after the test, the next operation trying to access the table (such as 'sysctl -a') will trigger a crash. Unregister the registered table after test completiion to solve the problem. Fixes: b5ffbd139688 ("sysctl: move the extra1/2 boundary check of u8 to sysctl_check_table_array") Cc: Wen Yang <wen.yang@xxxxxxxxx> Cc: Joel Granados <joel.granados@xxxxxxxxxx> Signed-off-by: Guenter Roeck <linux@xxxxxxxxxxxx> --- kernel/sysctl-test.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kernel/sysctl-test.c b/kernel/sysctl-test.c index eb2842bd0557..ac84f64dbdeb 100644 --- a/kernel/sysctl-test.c +++ b/kernel/sysctl-test.c @@ -374,6 +374,7 @@ static void sysctl_test_register_sysctl_sz_invalid_extra_value( struct kunit *test) { unsigned char data = 0; + struct ctl_table_header *header; const struct ctl_table table_foo[] = { { .procname = "foo", @@ -412,7 +413,9 @@ static void sysctl_test_register_sysctl_sz_invalid_extra_value( KUNIT_EXPECT_NULL(test, register_sysctl("foo", table_foo)); KUNIT_EXPECT_NULL(test, register_sysctl("foo", table_bar)); - KUNIT_EXPECT_NOT_NULL(test, register_sysctl("foo", table_qux)); + header = register_sysctl("foo", table_qux); + KUNIT_EXPECT_NOT_NULL(test, header); + unregister_sysctl_table(header); } static struct kunit_case sysctl_test_cases[] = { -- 2.45.2