]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ALSA: via82xx: Use safer strscpy() instead of strcpy()
authorTakashi Iwai <tiwai@suse.de>
Thu, 10 Jul 2025 10:07:08 +0000 (12:07 +0200)
committerTakashi Iwai <tiwai@suse.de>
Fri, 11 Jul 2025 07:53:34 +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-87-tiwai@suse.de
sound/pci/via82xx.c
sound/pci/via82xx_modem.c

index a04dbc0a420f6f81cc9d36b225aa634176099efa..0753c0c73f514395100b1921120011db2a215185 100644 (file)
@@ -1436,7 +1436,7 @@ static int snd_via8233_pcm_new(struct via82xx *chip)
        snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_via8233_playback_ops);
        snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_via8233_capture_ops);
        pcm->private_data = chip;
-       strcpy(pcm->name, chip->card->shortname);
+       strscpy(pcm->name, chip->card->shortname);
        chip->pcms[0] = pcm;
        /* set up playbacks */
        for (i = 0; i < 4; i++)
@@ -1461,7 +1461,7 @@ static int snd_via8233_pcm_new(struct via82xx *chip)
        snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_via8233_multi_ops);
        snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_via8233_capture_ops);
        pcm->private_data = chip;
-       strcpy(pcm->name, chip->card->shortname);
+       strscpy(pcm->name, chip->card->shortname);
        chip->pcms[1] = pcm;
        /* set up playback */
        init_viadev(chip, chip->multi_devno, VIA_REG_MULTPLAY_STATUS, 4, 0);
@@ -1504,7 +1504,7 @@ static int snd_via8233a_pcm_new(struct via82xx *chip)
        snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_via8233_multi_ops);
        snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_via8233_capture_ops);
        pcm->private_data = chip;
-       strcpy(pcm->name, chip->card->shortname);
+       strscpy(pcm->name, chip->card->shortname);
        chip->pcms[0] = pcm;
        /* set up playback */
        init_viadev(chip, chip->multi_devno, VIA_REG_MULTPLAY_STATUS, 4, 0);
@@ -1532,7 +1532,7 @@ static int snd_via8233a_pcm_new(struct via82xx *chip)
                return err;
        snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_via8233_playback_ops);
        pcm->private_data = chip;
-       strcpy(pcm->name, chip->card->shortname);
+       strscpy(pcm->name, chip->card->shortname);
        chip->pcms[1] = pcm;
        /* set up playback */
        init_viadev(chip, chip->playback_devno, 0x30, 3, 0);
@@ -1562,7 +1562,7 @@ static int snd_via686_pcm_new(struct via82xx *chip)
        snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_via686_playback_ops);
        snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_via686_capture_ops);
        pcm->private_data = chip;
-       strcpy(pcm->name, chip->card->shortname);
+       strscpy(pcm->name, chip->card->shortname);
        chip->pcms[0] = pcm;
        init_viadev(chip, 0, VIA_REG_PLAYBACK_STATUS, 0, 0);
        init_viadev(chip, 1, VIA_REG_CAPTURE_STATUS, 0, 1);
@@ -2461,7 +2461,7 @@ static int __snd_via82xx_probe(struct pci_dev *pci,
        card_type = pci_id->driver_data;
        switch (card_type) {
        case TYPE_CARD_VIA686:
-               strcpy(card->driver, "VIA686A");
+               strscpy(card->driver, "VIA686A");
                sprintf(card->shortname, "VIA 82C686A/B rev%x", pci->revision);
                chip_type = TYPE_VIA686;
                break;
@@ -2471,7 +2471,7 @@ static int __snd_via82xx_probe(struct pci_dev *pci,
                for (i = 0; i < ARRAY_SIZE(via823x_cards); i++) {
                        if (pci->revision == via823x_cards[i].revision) {
                                chip_type = via823x_cards[i].type;
-                               strcpy(card->shortname, via823x_cards[i].name);
+                               strscpy(card->shortname, via823x_cards[i].name);
                                break;
                        }
                }
@@ -2487,11 +2487,11 @@ static int __snd_via82xx_probe(struct pci_dev *pci,
                                chip_type = TYPE_VIA8233;
                }
                if (chip_type == TYPE_VIA8233A)
-                       strcpy(card->driver, "VIA8233A");
+                       strscpy(card->driver, "VIA8233A");
                else if (pci->revision >= VIA_REV_8237)
-                       strcpy(card->driver, "VIA8237"); /* no slog assignment */
+                       strscpy(card->driver, "VIA8237"); /* no slog assignment */
                else
-                       strcpy(card->driver, "VIA8233");
+                       strscpy(card->driver, "VIA8233");
                break;
        default:
                dev_err(card->dev, "invalid card type %d\n", card_type);
index eef0f9ddaae07e6c289486a9c8cf5a2a09510993..12a8c620724d2ad55244795a1c569790b7ffd9fd 100644 (file)
@@ -842,7 +842,7 @@ static int snd_via686_pcm_new(struct via82xx_modem *chip)
        snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_via686_capture_ops);
        pcm->dev_class = SNDRV_PCM_CLASS_MODEM;
        pcm->private_data = chip;
-       strcpy(pcm->name, chip->card->shortname);
+       strscpy(pcm->name, chip->card->shortname);
        chip->pcms[0] = pcm;
        init_viadev(chip, 0, VIA_REG_MO_STATUS, 0);
        init_viadev(chip, 1, VIA_REG_MI_STATUS, 1);
@@ -1116,7 +1116,7 @@ static int __snd_via82xx_probe(struct pci_dev *pci,
        card_type = pci_id->driver_data;
        switch (card_type) {
        case TYPE_CARD_VIA82XX_MODEM:
-               strcpy(card->driver, "VIA82XX-MODEM");
+               strscpy(card->driver, "VIA82XX-MODEM");
                sprintf(card->shortname, "VIA 82XX modem");
                break;
        default: