diff mbox series

lib/test: use after free in register_test_dev_kmod()

Message ID 20220324055207.GA21683@kili (mailing list archive)
State New
Headers show
Series lib/test: use after free in register_test_dev_kmod() | expand

Commit Message

Dan Carpenter March 24, 2022, 5:52 a.m. UTC
The "test_dev" pointer is freed but then returned to the caller.

Fixes: d9c6a72d6fa2 ("kmod: add test driver to stress test the module loader")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 lib/test_kmod.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Luis Chamberlain March 24, 2022, 11:18 p.m. UTC | #1
On Thu, Mar 24, 2022 at 08:52:07AM +0300, Dan Carpenter wrote:
> The "test_dev" pointer is freed but then returned to the caller.
> 
> Fixes: d9c6a72d6fa2 ("kmod: add test driver to stress test the module loader")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thanks queued onto modules-testing!

  Luis
diff mbox series

Patch

diff --git a/lib/test_kmod.c b/lib/test_kmod.c
index ce1589391413..cb800b1d0d99 100644
--- a/lib/test_kmod.c
+++ b/lib/test_kmod.c
@@ -1149,6 +1149,7 @@  static struct kmod_test_device *register_test_dev_kmod(void)
 	if (ret) {
 		pr_err("could not register misc device: %d\n", ret);
 		free_test_dev_kmod(test_dev);
+		test_dev = NULL;
 		goto out;
 	}