[PATCH 2/2] ftrace: replace simple_strtol() by kstrtol()

From: xywang . sjtu
Date: Mon Jul 15 2019 - 05:24:11 EST


From: Wang Xiayang <xywang.sjtu@xxxxxxxxxxx>

The simple_strtol() function is deprecated. kstrtol() is
the correct replacement as it can properly handle overflows.

This patch replaces the deprecated simple_strtol() use introduced recently.
Same as the case of invalid index, it returns zero on string parsing error.

Fixes: f79b3f338564 ("ftrace: Allow enabling of filters via index of available_filter_functions")
Signed-off-by: Wang Xiayang <xywang.sjtu@xxxxxxxxxxx>
---
kernel/trace/ftrace.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index 576c41644e77..2baabf51a61a 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -3701,10 +3701,13 @@ static int
add_rec_by_index(struct ftrace_hash *hash, struct ftrace_glob *func_g,
int clear_filter)
{
- long index = simple_strtoul(func_g->search, NULL, 0);
+ long index;
struct ftrace_page *pg;
struct dyn_ftrace *rec;

+ if (kstrtoul(func_g->search, 0, &index))
+ return 0;
+
/* The index starts at 1 */
if (--index < 0)
return 0;
--
2.11.0