auxdisplay: linedisp: Use kmemdup_nul() helper

Use the existing kmemdup_nul() helper instead of open-coding the same
operation.

Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
This commit is contained in:
Geert Uytterhoeven 2021-10-19 16:45:06 +02:00 committed by Miguel Ojeda
parent 7e76aece6f
commit 364f2c392f

View File

@ -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;