[bug report] ALSA: als300: Allocate resources with device-managed APIs
Dan Carpenter
dan.carpenter at oracle.com
Wed Jul 21 15:45:20 CEST 2021
Hello Takashi Iwai,
The patch 21a9314cf93b: "ALSA: als300: Allocate resources with
device-managed APIs" from Jul 15, 2021, leads to the following static
checker warning:
sound/pci/als300.c:713 snd_als300_probe()
error: potentially dereferencing uninitialized 'chip'.
sound/pci/als300.c
686 static int snd_als300_probe(struct pci_dev *pci,
687 const struct pci_device_id *pci_id)
688 {
689 static int dev;
690 struct snd_card *card;
691 struct snd_als300 *chip;
692 int err, chip_type;
693
694 if (dev >= SNDRV_CARDS)
695 return -ENODEV;
696 if (!enable[dev]) {
697 dev++;
698 return -ENOENT;
699 }
700
701 err = snd_devm_card_new(&pci->dev, index[dev], id[dev], THIS_MODULE,
702 sizeof(*chip), &card);
703 if (err < 0)
704 return err;
705
706 chip_type = pci_id->driver_data;
707
708 err = snd_als300_create(card, pci, chip_type);
709 if (err < 0)
710 return err;
711
712 strcpy(card->driver, "ALS300");
--> 713 if (chip->chip_type == DEVICE_ALS300_PLUS)
^^^^^^^^^^^^^^^
chip isn't initialized now.
714 /* don't know much about ALS300+ yet
715 * print revision number for now */
716 sprintf(card->shortname, "ALS300+ (Rev. %d)", chip->revision);
717 else
718 sprintf(card->shortname, "ALS300 (Rev. %c)", 'A' +
719 chip->revision - 1);
720 sprintf(card->longname, "%s at 0x%lx irq %i",
721 card->shortname, chip->port, chip->irq);
722
723 err = snd_card_register(card);
724 if (err < 0)
725 return err;
726
727 pci_set_drvdata(pci, card);
728 dev++;
729 return 0;
730 }
regards,
dan carpenter
More information about the Alsa-devel
mailing list