auxdisplay: linedisp: Use kmemdup_nul() helper
authorGeert Uytterhoeven <geert@linux-m68k.org>
Tue, 19 Oct 2021 14:45:06 +0000 (16:45 +0200)
committerMiguel Ojeda <ojeda@kernel.org>
Thu, 21 Oct 2021 21:36:29 +0000 (23:36 +0200)
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>
drivers/auxdisplay/line-display.c

index 4b97c20ac0b381ee67d0c58581c6c316b902c5c4..3f35199bc39f511fc3f6b67b1d1f894ce24b4a95 100644 (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;