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/20240213162741.3102810-1-andriy.shevchenko@linux.intel.com Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Reviewed-by: Luis Chamberlain <mcgrof@kernel.org> Cc: Jason Baron <jbaron@akamai.com> Cc: Jim Cromie <jim.cromie@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent 2932fb0 commit 9bea621

1 file changed

Lines changed: 3 additions & 4 deletions

File tree

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)