diff mbox series

[v4,4/4] test_kmod: Avoid potential double free in trigger_config_run_type()

Message ID 1587452704-1299-5-git-send-email-yangtiezhu@loongson.cn
State Superseded
Headers show
Series [v4,1/4] selftests: kmod: Use variable NAME in kmod_test_0001() | expand

Commit Message

Tiezhu Yang April 21, 2020, 7:05 a.m. UTC
Reset the member "test_fs" of the test configuration after a call
of the function "kfree_const" to a null pointer so that a double
memory release will not be performed.

Fixes: d9c6a72d6fa2 ("kmod: add test driver to stress test the module loader")
Acked-by: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---

v4:
  - no changes

v3:
  - use the quotes with correct format in the commit message,
    sorry for that

v2:
  - update the commit message suggested by Markus Elfring
  - add the Fixes tag

 lib/test_kmod.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/lib/test_kmod.c b/lib/test_kmod.c
index e651c37..eab5277 100644
--- a/lib/test_kmod.c
+++ b/lib/test_kmod.c
@@ -745,7 +745,7 @@  static int trigger_config_run_type(struct kmod_test_device *test_dev,
 		break;
 	case TEST_KMOD_FS_TYPE:
 		kfree_const(config->test_fs);
-		config->test_driver = NULL;
+		config->test_fs = NULL;
 		copied = config_copy_test_fs(config, test_str,
 					     strlen(test_str));
 		break;