diff mbox series

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

Message ID 1587187200-13109-4-git-send-email-yangtiezhu@loongson.cn (mailing list archive)
State New
Headers show
Series [1/4] selftests: kmod: Use variable NAME in kmod_test_0001() | expand

Commit Message

Tiezhu Yang April 18, 2020, 5:20 a.m. UTC
It should set config->test_fs instead of config->test_driver as NULL
after kfree_const(config->test_fs) to avoid potential double free.

Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 lib/test_kmod.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Luis Chamberlain April 18, 2020, 5:47 a.m. UTC | #1
On Sat, Apr 18, 2020 at 01:20:00PM +0800, Tiezhu Yang wrote:
> It should set config->test_fs instead of config->test_driver as NULL
> after kfree_const(config->test_fs) to avoid potential double free.
> 
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>

Acked-by:  Luis Chamberlain <mcgrof@kernel.org>

   Luis
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;