]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ALSA: opti9xx: Use safer strscpy() instead of strcpy()
authorTakashi Iwai <tiwai@suse.de>
Thu, 10 Jul 2025 10:06:16 +0000 (12:06 +0200)
committerTakashi Iwai <tiwai@suse.de>
Fri, 11 Jul 2025 07:53:15 +0000 (09:53 +0200)
Use a safer function strscpy() instead of strcpy() for copying to
arrays.

Only idiomatic code replacement, and no functional changes.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Link: https://patch.msgid.link/20250710100727.22653-35-tiwai@suse.de
sound/isa/opti9xx/miro.c
sound/isa/opti9xx/opti92x-ad1848.c

index 31d736d1dd1011a186811af4d2d4e518c0011a28..ad7180d7c0c2b1ac6da997f110868c64f66885c7 100644 (file)
@@ -718,10 +718,10 @@ static int snd_miro_mixer(struct snd_card *card,
 
        switch (miro->hardware) {
        case OPTi9XX_HW_82C924:
-               strcpy(card->mixername, "ACI & OPTi924");
+               strscpy(card->mixername, "ACI & OPTi924");
                break;
        case OPTi9XX_HW_82C929:
-               strcpy(card->mixername, "ACI & OPTi929");
+               strscpy(card->mixername, "ACI & OPTi929");
                break;
        default:
                snd_BUG();
@@ -779,7 +779,7 @@ static int snd_miro_init(struct snd_miro *chip,
        static const int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2};
 
        chip->hardware = hardware;
-       strcpy(chip->name, snd_opti9xx_names[hardware]);
+       strscpy(chip->name, snd_opti9xx_names[hardware]);
 
        chip->mc_base_size = opti9xx_mc_size[hardware];  
 
@@ -1351,7 +1351,7 @@ static int snd_miro_probe(struct snd_card *card)
                sprintf(card->shortname, "unknown Cardinal Technologies");
        }
 
-       strcpy(card->driver, "miro");
+       strscpy(card->driver, "miro");
        scnprintf(card->longname, sizeof(card->longname),
                  "%s: OPTi%s, %s at 0x%lx, irq %d, dma %d&%d",
                  card->shortname, miro->name, codec->pcm->name,
index a07a665d93dca8a37e03bdb0c092c0db10db2f87..328d043a1619384797f26ac059c119aa3c11a1b4 100644 (file)
@@ -171,7 +171,7 @@ static int snd_opti9xx_init(struct snd_opti9xx *chip,
        static const int opti9xx_mc_size[] = {7, 7, 10, 10, 2, 2, 2};
 
        chip->hardware = hardware;
-       strcpy(chip->name, snd_opti9xx_names[hardware]);
+       strscpy(chip->name, snd_opti9xx_names[hardware]);
 
        spin_lock_init(&chip->lock);
 
@@ -594,35 +594,35 @@ static int snd_opti93x_mixer(struct snd_wss *chip)
 
        card = chip->card;
 
-       strcpy(card->mixername, chip->pcm->name);
+       strscpy(card->mixername, chip->pcm->name);
 
        memset(&id1, 0, sizeof(id1));
        memset(&id2, 0, sizeof(id2));
        id1.iface = id2.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
        /* reassign AUX0 switch to CD */
-       strcpy(id1.name, "Aux Playback Switch");
-       strcpy(id2.name, "CD Playback Switch");
+       strscpy(id1.name, "Aux Playback Switch");
+       strscpy(id2.name, "CD Playback Switch");
        err = snd_ctl_rename_id(card, &id1, &id2);
        if (err < 0) {
                dev_err(card->dev, "Cannot rename opti93x control\n");
                return err;
        }
        /* reassign AUX1 switch to FM */
-       strcpy(id1.name, "Aux Playback Switch"); id1.index = 1;
-       strcpy(id2.name, "FM Playback Switch");
+       strscpy(id1.name, "Aux Playback Switch"); id1.index = 1;
+       strscpy(id2.name, "FM Playback Switch");
        err = snd_ctl_rename_id(card, &id1, &id2);
        if (err < 0) {
                dev_err(card->dev, "Cannot rename opti93x control\n");
                return err;
        }
        /* remove AUX1 volume */
-       strcpy(id1.name, "Aux Playback Volume"); id1.index = 1;
+       strscpy(id1.name, "Aux Playback Volume"); id1.index = 1;
        snd_ctl_remove_id(card, &id1);
 
        /* Replace WSS volume controls with OPTi93x volume controls */
        id1.index = 0;
        for (idx = 0; idx < ARRAY_SIZE(snd_opti93x_controls); idx++) {
-               strcpy(id1.name, snd_opti93x_controls[idx].name);
+               strscpy(id1.name, snd_opti93x_controls[idx].name);
                snd_ctl_remove_id(card, &id1);
 
                err = snd_ctl_add(card,
@@ -857,7 +857,7 @@ static int snd_opti9xx_probe(struct snd_card *card)
 #endif
        chip->irq = irq;
        card->sync_irq = chip->irq;
-       strcpy(card->driver, chip->name);
+       strscpy(card->driver, chip->name);
        sprintf(card->shortname, "OPTi %s", card->driver);
 #if defined(CS4231) || defined(OPTi93X)
        scnprintf(card->longname, sizeof(card->longname),