alsa-devel.alsa-project.org archive mirror
 help / color / mirror / Atom feed
* [bug report] ALSA: als300: Allocate resources with device-managed APIs
@ 2021-07-21 13:45 Dan Carpenter
  2021-07-21 13:58 ` Takashi Iwai
  0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2021-07-21 13:45 UTC (permalink / raw)
  To: tiwai; +Cc: alsa-devel

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-07-21 13:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-21 13:45 [bug report] ALSA: als300: Allocate resources with device-managed APIs Dan Carpenter
2021-07-21 13:58 ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).