Commit 688956f23bdbfb1c3551bfafc819f989b36bb8ae
Committed by
Jaroslav Kysela
1 parent
c5533bf36b
Exists in
master
and in
7 other branches
[ALSA] Fix races in irq handler and ioremap
Call ioremap before request_irq for avoiding possible races in the irq handler. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Showing 3 changed files with 18 additions and 18 deletions Side-by-side Diff
sound/pci/cs4281.c
| ... | ... | @@ -1379,6 +1379,13 @@ |
| 1379 | 1379 | chip->ba0_addr = pci_resource_start(pci, 0); |
| 1380 | 1380 | chip->ba1_addr = pci_resource_start(pci, 1); |
| 1381 | 1381 | |
| 1382 | + chip->ba0 = ioremap_nocache(chip->ba0_addr, pci_resource_len(pci, 0)); | |
| 1383 | + chip->ba1 = ioremap_nocache(chip->ba1_addr, pci_resource_len(pci, 1)); | |
| 1384 | + if (!chip->ba0 || !chip->ba1) { | |
| 1385 | + snd_cs4281_free(chip); | |
| 1386 | + return -ENOMEM; | |
| 1387 | + } | |
| 1388 | + | |
| 1382 | 1389 | if (request_irq(pci->irq, snd_cs4281_interrupt, SA_INTERRUPT|SA_SHIRQ, |
| 1383 | 1390 | "CS4281", chip)) { |
| 1384 | 1391 | snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); |
| ... | ... | @@ -1387,13 +1394,6 @@ |
| 1387 | 1394 | } |
| 1388 | 1395 | chip->irq = pci->irq; |
| 1389 | 1396 | |
| 1390 | - chip->ba0 = ioremap_nocache(chip->ba0_addr, pci_resource_len(pci, 0)); | |
| 1391 | - chip->ba1 = ioremap_nocache(chip->ba1_addr, pci_resource_len(pci, 1)); | |
| 1392 | - if (!chip->ba0 || !chip->ba1) { | |
| 1393 | - snd_cs4281_free(chip); | |
| 1394 | - return -ENOMEM; | |
| 1395 | - } | |
| 1396 | - | |
| 1397 | 1397 | tmp = snd_cs4281_chip_init(chip); |
| 1398 | 1398 | if (tmp) { |
| 1399 | 1399 | snd_cs4281_free(chip); |
sound/pci/rme32.c
| ... | ... | @@ -1368,17 +1368,17 @@ |
| 1368 | 1368 | return err; |
| 1369 | 1369 | rme32->port = pci_resource_start(rme32->pci, 0); |
| 1370 | 1370 | |
| 1371 | - if (request_irq(pci->irq, snd_rme32_interrupt, SA_INTERRUPT | SA_SHIRQ, "RME32", (void *) rme32)) { | |
| 1372 | - snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); | |
| 1373 | - return -EBUSY; | |
| 1374 | - } | |
| 1375 | - rme32->irq = pci->irq; | |
| 1376 | - | |
| 1377 | 1371 | if ((rme32->iobase = ioremap_nocache(rme32->port, RME32_IO_SIZE)) == 0) { |
| 1378 | 1372 | snd_printk(KERN_ERR "unable to remap memory region 0x%lx-0x%lx\n", |
| 1379 | 1373 | rme32->port, rme32->port + RME32_IO_SIZE - 1); |
| 1380 | 1374 | return -ENOMEM; |
| 1381 | 1375 | } |
| 1376 | + | |
| 1377 | + if (request_irq(pci->irq, snd_rme32_interrupt, SA_INTERRUPT | SA_SHIRQ, "RME32", (void *) rme32)) { | |
| 1378 | + snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); | |
| 1379 | + return -EBUSY; | |
| 1380 | + } | |
| 1381 | + rme32->irq = pci->irq; | |
| 1382 | 1382 | |
| 1383 | 1383 | /* read the card's revision number */ |
| 1384 | 1384 | pci_read_config_byte(pci, 8, &rme32->rev); |
sound/pci/rme96.c
| ... | ... | @@ -1583,16 +1583,16 @@ |
| 1583 | 1583 | return err; |
| 1584 | 1584 | rme96->port = pci_resource_start(rme96->pci, 0); |
| 1585 | 1585 | |
| 1586 | + if ((rme96->iobase = ioremap_nocache(rme96->port, RME96_IO_SIZE)) == 0) { | |
| 1587 | + snd_printk(KERN_ERR "unable to remap memory region 0x%lx-0x%lx\n", rme96->port, rme96->port + RME96_IO_SIZE - 1); | |
| 1588 | + return -ENOMEM; | |
| 1589 | + } | |
| 1590 | + | |
| 1586 | 1591 | if (request_irq(pci->irq, snd_rme96_interrupt, SA_INTERRUPT|SA_SHIRQ, "RME96", (void *)rme96)) { |
| 1587 | 1592 | snd_printk(KERN_ERR "unable to grab IRQ %d\n", pci->irq); |
| 1588 | 1593 | return -EBUSY; |
| 1589 | 1594 | } |
| 1590 | 1595 | rme96->irq = pci->irq; |
| 1591 | - | |
| 1592 | - if ((rme96->iobase = ioremap_nocache(rme96->port, RME96_IO_SIZE)) == 0) { | |
| 1593 | - snd_printk(KERN_ERR "unable to remap memory region 0x%lx-0x%lx\n", rme96->port, rme96->port + RME96_IO_SIZE - 1); | |
| 1594 | - return -ENOMEM; | |
| 1595 | - } | |
| 1596 | 1596 | |
| 1597 | 1597 | /* read the card's revision number */ |
| 1598 | 1598 | pci_read_config_byte(pci, 8, &rme96->rev); |