lkml.org 
[lkml]   [2021]   [Mar]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] lib/test_kmod: Fix a use after free in register_test_dev_kmod
Date
In register_test_dev_kmod, it calls free_test_dev_kmod() to free
test_dev. But free_test_dev_kmod() can't set the original pointer
test_dev to NULL, because the test_dev was passed by it's value
not reference.

Signed-off-by: Lv Yunlong <lyl2019@mail.ustc.edu.cn>
---
lib/test_kmod.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/test_kmod.c b/lib/test_kmod.c
index 38c250fbace3..aa8a2a563d7e 100644
--- a/lib/test_kmod.c
+++ b/lib/test_kmod.c
@@ -1124,7 +1124,6 @@ static void free_test_dev_kmod(struct kmod_test_device *test_dev)
free_test_dev_info(test_dev);
kmod_config_free(test_dev);
vfree(test_dev);
- test_dev = NULL;
}
}

@@ -1149,6 +1148,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;
}

--
2.25.1

\
 
 \ /
  Last update: 2021-03-11 09:05    [W:0.456 / U:0.256 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site