All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: tiwai@suse.de
Cc: alsa-devel@alsa-project.org
Subject: [bug report] ALSA: als300: Allocate resources with device-managed APIs
Date: Wed, 21 Jul 2021 06:45:20 -0700	[thread overview]
Message-ID: <20210721134520.GA2850@kili> (raw)

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

             reply	other threads:[~2021-07-21 13:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-21 13:45 Dan Carpenter [this message]
2021-07-21 13:58 ` [bug report] ALSA: als300: Allocate resources with device-managed APIs Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210721134520.GA2850@kili \
    --to=dan.carpenter@oracle.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.