Skip to content

Commit 1c1857d

Browse files
x2018rostedt
authored andcommitted
tracing/probes: check the return value of kstrndup() for pbuf
kstrndup() is a memory allocation-related function, it returns NULL when some internal memory errors happen. It is better to check the return value of it so to catch the memory error in time. Link: https://lkml.kernel.org/r/[email protected] Acked-by: Masami Hiramatsu <[email protected]> Fixes: a42e3c4 ("tracing/probe: Add immediate string parameter support") Signed-off-by: Xiaoke Wang <[email protected]> Signed-off-by: Steven Rostedt <[email protected]>
1 parent 8c72242 commit 1c1857d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

kernel/trace/trace_probe.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,8 @@ static int __parse_imm_string(char *str, char **pbuf, int offs)
356356
return -EINVAL;
357357
}
358358
*pbuf = kstrndup(str, len - 1, GFP_KERNEL);
359+
if (!*pbuf)
360+
return -ENOMEM;
359361
return 0;
360362
}
361363

0 commit comments

Comments
 (0)