]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - sound/pci/pcxhr/pcxhr.c
Merge branch 'topic/pcsp-fix' into topic/misc
[linux-2.6-omap-h63xx.git] / sound / pci / pcxhr / pcxhr.c
index 2c7e25336795d6bfb6588019069ff77947163e61..7d2b136295d5304249aef42362dbf7f148487973 100644 (file)
@@ -464,7 +464,8 @@ static int pcxhr_update_r_buffer(struct pcxhr_stream *stream)
        pcxhr_init_rmh(&rmh, CMD_UPDATE_R_BUFFERS);
        pcxhr_set_pipe_cmd_params(&rmh, is_capture, stream->pipe->first_audio, stream_num, 0);
 
-       snd_assert(subs->runtime->dma_bytes < 0x200000);        /* max buffer size is 2 MByte */
+       /* max buffer size is 2 MByte */
+       snd_BUG_ON(subs->runtime->dma_bytes >= 0x200000);
        rmh.cmd[1] = subs->runtime->dma_bytes * 8;              /* size in bits */
        rmh.cmd[2] = subs->runtime->dma_addr >> 24;             /* most significant byte */
        rmh.cmd[2] |= 1<<19;                                    /* this is a circular buffer */
@@ -1023,7 +1024,7 @@ static int __devinit pcxhr_create(struct pcxhr_mgr *mgr, struct snd_card *card,
                .dev_free = pcxhr_chip_dev_free,
        };
 
-       mgr->chip[idx] = chip = kzalloc(sizeof(*chip), GFP_KERNEL);
+       chip = kzalloc(sizeof(*chip), GFP_KERNEL);
        if (! chip) {
                snd_printk(KERN_ERR "cannot allocate chip\n");
                return -ENOMEM;
@@ -1049,6 +1050,7 @@ static int __devinit pcxhr_create(struct pcxhr_mgr *mgr, struct snd_card *card,
                return err;
        }
 
+       mgr->chip[idx] = chip;
        snd_card_set_dev(card, &mgr->pci->dev);
 
        return 0;
@@ -1228,7 +1230,11 @@ static int __devinit pcxhr_probe(struct pci_dev *pci, const struct pci_device_id
                return -ENOMEM;
        }
 
-       snd_assert(pci_id->driver_data < PCI_ID_LAST, return -ENODEV);
+       if (snd_BUG_ON(pci_id->driver_data >= PCI_ID_LAST)) {
+               kfree(mgr);
+               pci_disable_device(pci);
+               return -ENODEV;
+       }
        card_name = pcxhr_board_params[pci_id->driver_data].board_name;
        mgr->playback_chips = pcxhr_board_params[pci_id->driver_data].playback_chips;
        mgr->capture_chips  = pcxhr_board_params[pci_id->driver_data].capture_chips;
@@ -1305,6 +1311,7 @@ static int __devinit pcxhr_probe(struct pci_dev *pci, const struct pci_device_id
                sprintf(card->longname, "%s [PCM #%d]", mgr->longname, i);
 
                if ((err = pcxhr_create(mgr, card, i)) < 0) {
+                       snd_card_free(card);
                        pcxhr_free(mgr);
                        return err;
                }