lkml.org 
[lkml]   [2017]   [Oct]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v3 2/2] kprobes: initialize probed_mod to NULL
Date
When check_kprobe_address_safe() return fail, the probed_mod
should be set to NULL, because no module refcount held. And we
initialize probed_mod to NULL in register_kprobe() for the same reason.

Signed-off-by: Zhou Chengming <zhouchengming1@huawei.com>
---
kernel/kprobes.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/kernel/kprobes.c b/kernel/kprobes.c
index 1eeedac..a04588c 100644
--- a/kernel/kprobes.c
+++ b/kernel/kprobes.c
@@ -1488,6 +1488,7 @@ static int check_kprobe_address_safe(struct kprobe *p,
* its code to prohibit unexpected unloading.
*/
if (unlikely(!try_module_get(*probed_mod))) {
+ *probed_mod = NULL;
ret = -ENOENT;
goto out;
}
@@ -1514,7 +1515,7 @@ int register_kprobe(struct kprobe *p)
{
int ret;
struct kprobe *old_p;
- struct module *probed_mod;
+ struct module *probed_mod = NULL;
kprobe_opcode_t *addr;

/* Adjust probe address from symbol */
--
1.8.3.1
\
 
 \ /
  Last update: 2017-10-28 20:17    [W:0.208 / U:0.044 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site