lkml.org 
[lkml]   [2021]   [Jun]   [25]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 07/18] auxdisplay: linedisp: Use kmemdup_nul() helper
Date
Use the existing kmemdup_nul() helper instead of open-coding the same
operation.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
v2:
- No changes.
---
drivers/auxdisplay/line-display.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/auxdisplay/line-display.c b/drivers/auxdisplay/line-display.c
index 4b97c20ac0b381ee..3f35199bc39f511f 100644
--- a/drivers/auxdisplay/line-display.c
+++ b/drivers/auxdisplay/line-display.c
@@ -91,13 +91,10 @@ static int linedisp_display(struct linedisp *linedisp, const char *msg,
return 0;
}

- new_msg = kmalloc(count + 1, GFP_KERNEL);
+ new_msg = kmemdup_nul(msg, count, GFP_KERNEL);
if (!new_msg)
return -ENOMEM;

- memcpy(new_msg, msg, count);
- new_msg[count] = 0;
-
kfree(linedisp->message);

linedisp->message = new_msg;
--
2.25.1
\
 
 \ /
  Last update: 2021-06-25 15:06    [W:0.196 / U:0.900 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site