Skip to contentSkip to conversation

lib/test_kmod: Potential double free in error handling

PATCH In review Dan Carpenter 2 participants 2 messages Jan 21, 2019 – Jan 22, 2019

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

PATCH 1/1 lib/test_kmod: Potential double free in error handling

There is a copy and paste bug so we set "config->test_driver" to NULL twice instead of setting "config->test_fs". Smatch complains that it leads to a double free:

lib/test_kmod.c:840 __kmod_config_init() warn: 'config->test_fs' double freed

Fixes d9c6a72d6fa2 ("kmod: add test driver to stress test the module loader")
---
 lib/test_kmod.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/test_kmod.c +1 -1
index d82d022111e0..9cf77628fc91 100644
@@ -632,7 +632,7 @@ static void __kmod_config_free(struct test_config *config)
 	config->test_driver = NULL;
 
 	kfree_const(config->test_fs);
-	config->test_driver = NULL;
+	config->test_fs = NULL;
 }
 
 static void kmod_config_free(struct kmod_test_device *test_dev)
Signature · 1 line
2.17.1
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 8 lines · Dan Carpenter

There is a copy and paste bug so we set "config->test_driver" to NULL twice instead of setting "config->test_fs". Smatch complains that it leads to a double free:

lib/test_kmod.c:840 __kmod_config_init() warn: 'config->test_fs' double freed

Fixes d9c6a72d6fa2 ("kmod: add test driver to stress test the module loader")

Thanks!

Luis