]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
usb: gadget: functionfs: Use safer strscpy() instead of strcpy()
authorAi Chao <aichao@kylinos.cn>
Tue, 10 Mar 2026 09:44:31 +0000 (17:44 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 11 Mar 2026 14:39:04 +0000 (15:39 +0100)
Use a safer function strscpy() instead of strcpy() for copying to
arrays.

Only idiomatic code replacement, and no functional changes.

Signed-off-by: Ai Chao <aichao@kylinos.cn>
Link: https://patch.msgid.link/20260310094434.3639602-4-aichao@kylinos.cn
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/gadget/function/f_midi2.c
drivers/usb/gadget/function/u_serial.c

index b5f0defde95d6a8893cacf0b5619d3b6c6166dad..19fdac0243439c5289a267708b051419e8288a0c 100644 (file)
@@ -1541,9 +1541,9 @@ static int f_midi2_create_card(struct f_midi2 *midi2)
                return err;
        midi2->card = card;
 
-       strcpy(card->driver, "f_midi2");
-       strcpy(card->shortname, "MIDI 2.0 Gadget");
-       strcpy(card->longname, "MIDI 2.0 Gadget");
+       strscpy(card->driver, "f_midi2");
+       strscpy(card->shortname, "MIDI 2.0 Gadget");
+       strscpy(card->longname, "MIDI 2.0 Gadget");
 
        id = 0;
        for (i = 0; i < midi2->num_eps; i++) {
index e43ad6373846512aae215c406184329be008eb45..cdd1dfc666c4f6b3ddb1530ef44e0c56ccd14a77 100644 (file)
@@ -1086,7 +1086,7 @@ static int gs_console_init(struct gs_port *port)
        if (!cons)
                return -ENOMEM;
 
-       strcpy(cons->console.name, "ttyGS");
+       strscpy(cons->console.name, "ttyGS");
        cons->console.write = gs_console_write;
        cons->console.device = gs_console_device;
        cons->console.flags = CON_PRINTBUFFER;