2021-03-30 10:04:28

by Jiapeng Chong

[permalink] [raw]
Subject: [PATCH] ftrace: Modify parameter transfer type

Fix the following whitescan warning:

"order" is passed to a parameter that cannot be negative.

Reported-by: Abaci Robot <[email protected]>
Signed-off-by: Jiapeng Chong <[email protected]>
---
kernel/trace/ftrace.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
index b7e29db..bd42e86 100644
--- a/kernel/trace/ftrace.c
+++ b/kernel/trace/ftrace.c
@@ -6811,7 +6811,7 @@ void ftrace_free_mem(struct module *mod, void *start_ptr, void *end_ptr)
if (!pg->index) {
*last_pg = pg->next;
order = get_count_order(pg->size / ENTRIES_PER_PAGE);
- free_pages((unsigned long)pg->records, order);
+ free_pages((unsigned long)pg->records, (unsigned int)order);
ftrace_number_of_pages -= 1 << order;
ftrace_number_of_groups--;
kfree(pg);
--
1.8.3.1


2021-03-30 13:43:38

by Steven Rostedt

[permalink] [raw]
Subject: Re: [PATCH] ftrace: Modify parameter transfer type

On Tue, 30 Mar 2021 18:02:26 +0800
Jiapeng Chong <[email protected]> wrote:

> Fix the following whitescan warning:
>
> "order" is passed to a parameter that cannot be negative.
>
> Reported-by: Abaci Robot <[email protected]>
> Signed-off-by: Jiapeng Chong <[email protected]>
> ---
> kernel/trace/ftrace.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c
> index b7e29db..bd42e86 100644
> --- a/kernel/trace/ftrace.c
> +++ b/kernel/trace/ftrace.c
> @@ -6811,7 +6811,7 @@ void ftrace_free_mem(struct module *mod, void *start_ptr, void *end_ptr)
> if (!pg->index) {
> *last_pg = pg->next;
> order = get_count_order(pg->size / ENTRIES_PER_PAGE);
> - free_pages((unsigned long)pg->records, order);
> + free_pages((unsigned long)pg->records, (unsigned int)order);

NAK!

This "fix" actually makes the problem worse, and hides a possible bug.

-- Steve


> ftrace_number_of_pages -= 1 << order;
> ftrace_number_of_groups--;
> kfree(pg);