Skip to content

Commit 9bea621

Browse files
andy-shevakpm00
authored andcommitted
dyndbg: replace kstrdup() + strchr() with kstrdup_and_replace()
Replace open coded functionalify of kstrdup_and_replace() with a call. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Andy Shevchenko <[email protected]> Reviewed-by: Luis Chamberlain <[email protected]> Cc: Jason Baron <[email protected]> Cc: Jim Cromie <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 2932fb0 commit 9bea621

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

lib/dynamic_debug.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -640,10 +640,9 @@ static int param_set_dyndbg_classnames(const char *instr, const struct kernel_pa
640640
int cls_id, totct = 0;
641641
bool wanted;
642642

643-
cl_str = tmp = kstrdup(instr, GFP_KERNEL);
644-
p = strchr(cl_str, '\n');
645-
if (p)
646-
*p = '\0';
643+
cl_str = tmp = kstrdup_and_replace(instr, '\n', '\0', GFP_KERNEL);
644+
if (!tmp)
645+
return -ENOMEM;
647646

648647
/* start with previously set state-bits, then modify */
649648
curr_bits = old_bits = *dcp->bits;

0 commit comments

Comments
 (0)