mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2025-01-23 09:23:00 +01:00
Check for a valid irq number before calling BUS_SETUP_INTR.
Requested-By: msmith
This commit is contained in:
parent
bf3367d091
commit
aa9b0faecb
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=51914
@ -56,7 +56,6 @@
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/queue.h>
|
||||
#include <machine/bus.h>
|
||||
@ -145,6 +144,7 @@ ohci_pci_attach(device_t self)
|
||||
int rid;
|
||||
struct resource *res;
|
||||
void *ih;
|
||||
int intr;
|
||||
|
||||
rid = PCI_CBMEM;
|
||||
res = bus_alloc_resource(self, SYS_RES_MEMORY, &rid,
|
||||
@ -200,6 +200,14 @@ ohci_pci_attach(device_t self)
|
||||
sprintf(sc->sc_vendor, "(unknown)");
|
||||
}
|
||||
|
||||
intr = pci_read_config(self, PCIR_INTLINE, 1);
|
||||
if (intr == 0 || intr == 255) {
|
||||
device_printf(self, "Invalid irq %d\n", intr);
|
||||
device_printf(self, "Please switch on USB support and switch PNP-OS to 'No' in BIOS\n");
|
||||
device_delete_child(self, usbus);
|
||||
return ENXIO;
|
||||
}
|
||||
|
||||
err = BUS_SETUP_INTR(parent, self, res, INTR_TYPE_BIO,
|
||||
(driver_intr_t *) ohci_intr, sc, &ih);
|
||||
if (err) {
|
||||
|
@ -54,7 +54,6 @@
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/queue.h>
|
||||
#if defined(__FreeBSD__)
|
||||
@ -158,6 +157,7 @@ uhci_pci_attach(device_t self)
|
||||
struct resource *res;
|
||||
device_t usbus;
|
||||
char *typestr;
|
||||
int intr;
|
||||
int legsup;
|
||||
int err;
|
||||
|
||||
@ -225,6 +225,14 @@ uhci_pci_attach(device_t self)
|
||||
typestr, pci_get_revid(self));
|
||||
}
|
||||
|
||||
intr = pci_read_config(self, PCIR_INTLINE, 1);
|
||||
if (intr == 0 || intr == 255) {
|
||||
device_printf(self, "Invalid irq %d\n", intr);
|
||||
device_printf(self, "Please switch on USB support and switch PNP-OS to 'No' in BIOS\n");
|
||||
device_delete_child(self, usbus);
|
||||
return ENXIO;
|
||||
}
|
||||
|
||||
err = BUS_SETUP_INTR(parent, self, res, INTR_TYPE_BIO,
|
||||
(driver_intr_t *) uhci_intr, sc, &ih);
|
||||
if (err) {
|
||||
@ -233,6 +241,7 @@ uhci_pci_attach(device_t self)
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Verify that the PIRQD enable bit is set, some BIOS's don't do that */
|
||||
legsup = pci_read_config(self, PCI_LEGSUP, 4);
|
||||
if ( !(legsup & PCI_LEGSUP_USBPIRQDEN) ) {
|
||||
#ifndef USB_DEBUG
|
||||
@ -248,11 +257,13 @@ uhci_pci_attach(device_t self)
|
||||
|
||||
if (!err)
|
||||
err = device_probe_and_attach(sc->sc_bus.bdev);
|
||||
|
||||
|
||||
if (err) {
|
||||
device_printf(self, "init failed\n");
|
||||
|
||||
/* disable interrupts */
|
||||
/* disable interrupts that might have been switched on
|
||||
* in uhci_init
|
||||
*/
|
||||
bus_space_write_2(sc->iot, sc->ioh, UHCI_INTR, 0);
|
||||
|
||||
err = BUS_TEARDOWN_INTR(parent, self, res, ih);
|
||||
|
@ -56,7 +56,6 @@
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/queue.h>
|
||||
#include <machine/bus.h>
|
||||
@ -145,6 +144,7 @@ ohci_pci_attach(device_t self)
|
||||
int rid;
|
||||
struct resource *res;
|
||||
void *ih;
|
||||
int intr;
|
||||
|
||||
rid = PCI_CBMEM;
|
||||
res = bus_alloc_resource(self, SYS_RES_MEMORY, &rid,
|
||||
@ -200,6 +200,14 @@ ohci_pci_attach(device_t self)
|
||||
sprintf(sc->sc_vendor, "(unknown)");
|
||||
}
|
||||
|
||||
intr = pci_read_config(self, PCIR_INTLINE, 1);
|
||||
if (intr == 0 || intr == 255) {
|
||||
device_printf(self, "Invalid irq %d\n", intr);
|
||||
device_printf(self, "Please switch on USB support and switch PNP-OS to 'No' in BIOS\n");
|
||||
device_delete_child(self, usbus);
|
||||
return ENXIO;
|
||||
}
|
||||
|
||||
err = BUS_SETUP_INTR(parent, self, res, INTR_TYPE_BIO,
|
||||
(driver_intr_t *) ohci_intr, sc, &ih);
|
||||
if (err) {
|
||||
|
@ -54,7 +54,6 @@
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/bus.h>
|
||||
#include <sys/device.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/queue.h>
|
||||
#if defined(__FreeBSD__)
|
||||
@ -158,6 +157,7 @@ uhci_pci_attach(device_t self)
|
||||
struct resource *res;
|
||||
device_t usbus;
|
||||
char *typestr;
|
||||
int intr;
|
||||
int legsup;
|
||||
int err;
|
||||
|
||||
@ -225,6 +225,14 @@ uhci_pci_attach(device_t self)
|
||||
typestr, pci_get_revid(self));
|
||||
}
|
||||
|
||||
intr = pci_read_config(self, PCIR_INTLINE, 1);
|
||||
if (intr == 0 || intr == 255) {
|
||||
device_printf(self, "Invalid irq %d\n", intr);
|
||||
device_printf(self, "Please switch on USB support and switch PNP-OS to 'No' in BIOS\n");
|
||||
device_delete_child(self, usbus);
|
||||
return ENXIO;
|
||||
}
|
||||
|
||||
err = BUS_SETUP_INTR(parent, self, res, INTR_TYPE_BIO,
|
||||
(driver_intr_t *) uhci_intr, sc, &ih);
|
||||
if (err) {
|
||||
@ -233,6 +241,7 @@ uhci_pci_attach(device_t self)
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Verify that the PIRQD enable bit is set, some BIOS's don't do that */
|
||||
legsup = pci_read_config(self, PCI_LEGSUP, 4);
|
||||
if ( !(legsup & PCI_LEGSUP_USBPIRQDEN) ) {
|
||||
#ifndef USB_DEBUG
|
||||
@ -248,11 +257,13 @@ uhci_pci_attach(device_t self)
|
||||
|
||||
if (!err)
|
||||
err = device_probe_and_attach(sc->sc_bus.bdev);
|
||||
|
||||
|
||||
if (err) {
|
||||
device_printf(self, "init failed\n");
|
||||
|
||||
/* disable interrupts */
|
||||
/* disable interrupts that might have been switched on
|
||||
* in uhci_init
|
||||
*/
|
||||
bus_space_write_2(sc->iot, sc->ioh, UHCI_INTR, 0);
|
||||
|
||||
err = BUS_TEARDOWN_INTR(parent, self, res, ih);
|
||||
|
Loading…
Reference in New Issue
Block a user