From: Geert Uytterhoeven Date: Tue, 19 Oct 2021 14:45:06 +0000 (+0200) Subject: auxdisplay: linedisp: Use kmemdup_nul() helper X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=364f2c392f2b38ba3c52933f11a8dbee71f28864;p=linux.git auxdisplay: linedisp: Use kmemdup_nul() helper Use the existing kmemdup_nul() helper instead of open-coding the same operation. Signed-off-by: Geert Uytterhoeven Signed-off-by: Miguel Ojeda --- diff --git a/drivers/auxdisplay/line-display.c b/drivers/auxdisplay/line-display.c index 4b97c20ac0b38..3f35199bc39f5 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;