Skip to contentSkip to conversation

dyndbg: Replace kstrdup() + strchr() with kstrdup_and_replace()

PATCH Applied Andy Shevchenko 2 participants 2 messages Feb 13, 2024

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dyndbg: Replace kstrdup() + strchr() with kstrdup_and_replace()

Replace open coded functionalify of kstrdup_and_replace() with a call.

---
 lib/dynamic_debug.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
lib/dynamic_debug.c +3 -4
index 6fba6423cc10..c78f335fa981 100644
@@ -640,10 +640,9 @@ static int param_set_dyndbg_classnames(const char *instr, const struct kernel_pa
 	int cls_id, totct = 0;
 	bool wanted;
 
-	cl_str = tmp = kstrdup(instr, GFP_KERNEL);
-	p = strchr(cl_str, '\n');
-	if (p)
-		*p = '\0';
+	cl_str = tmp = kstrdup_and_replace(instr, '\n', '\0', GFP_KERNEL);
+	if (!tmp)
+		return -ENOMEM;
 
 	/* start with previously set state-bits, then modify */
 	curr_bits = old_bits = *dcp->bits;
Signature · 1 line
2.43.0.rc1.1.gbec44491f096