lkml.org 
[lkml]   [2023]   [Jan]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] tracing/eprobe: Replace kzalloc with kmalloc
On Sat,  7 Jan 2023 11:45:57 +0800
Quanfa Fu <quanfafu@gmail.com> wrote:

> Since this memory will be filled soon below, I feel that there is
> no need for a memory of all zeros here. 'snprintf' does not return
> negative num according to ISO C99, so I feel that no judgment is
> needed here.
>
> No functional change intended.
>

Ah, good catch. I didn't notice that snprintf() doesn't return
error code. (I confirmed that the linux internal snprintf() also
doesn't return the error code)

Acked-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>

Thank you!

> Signed-off-by: Quanfa Fu <quanfafu@gmail.com>
> ---
> kernel/trace/trace_eprobe.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/kernel/trace/trace_eprobe.c b/kernel/trace/trace_eprobe.c
> index 352b65e2b910..cd1d271a74e7 100644
> --- a/kernel/trace/trace_eprobe.c
> +++ b/kernel/trace/trace_eprobe.c
> @@ -917,15 +917,13 @@ static int trace_eprobe_parse_filter(struct trace_eprobe *ep, int argc, const ch
> for (i = 0; i < argc; i++)
> len += strlen(argv[i]) + 1;
>
> - ep->filter_str = kzalloc(len, GFP_KERNEL);
> + ep->filter_str = kmalloc(len, GFP_KERNEL);
> if (!ep->filter_str)
> return -ENOMEM;
>
> p = ep->filter_str;
> for (i = 0; i < argc; i++) {
> ret = snprintf(p, len, "%s ", argv[i]);
> - if (ret < 0)
> - goto error;
> if (ret > len) {
> ret = -E2BIG;
> goto error;
> --
> 2.31.1
>


--
Masami Hiramatsu (Google) <mhiramat@kernel.org>

\
 
 \ /
  Last update: 2023-03-26 23:31    [W:0.166 / U:0.176 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site