rtwn_pci(4): fix possible race while accessing 'matched_chip' variable.
This commit is contained in:
parent
46fdfd5291
commit
c54d3d8756
@ -94,20 +94,31 @@ static void rtwn_pci_beacon_update_end(struct rtwn_softc *,
|
||||
static void rtwn_pci_attach_methods(struct rtwn_softc *);
|
||||
|
||||
|
||||
static int matched_chip = RTWN_CHIP_MAX_PCI;
|
||||
static const struct rtwn_pci_ident *
|
||||
rtwn_pci_probe_sub(device_t dev)
|
||||
{
|
||||
const struct rtwn_pci_ident *ident;
|
||||
int vendor_id, device_id;
|
||||
|
||||
vendor_id = pci_get_vendor(dev);
|
||||
device_id = pci_get_device(dev);
|
||||
|
||||
for (ident = rtwn_pci_ident_table; ident->name != NULL; ident++)
|
||||
if (vendor_id == ident->vendor && device_id == ident->device)
|
||||
return (ident);
|
||||
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
static int
|
||||
rtwn_pci_probe(device_t dev)
|
||||
{
|
||||
const struct rtwn_pci_ident *ident;
|
||||
|
||||
for (ident = rtwn_pci_ident_table; ident->name != NULL; ident++) {
|
||||
if (pci_get_vendor(dev) == ident->vendor &&
|
||||
pci_get_device(dev) == ident->device) {
|
||||
matched_chip = ident->chip;
|
||||
device_set_desc(dev, ident->name);
|
||||
return (BUS_PROBE_DEFAULT);
|
||||
}
|
||||
ident = rtwn_pci_probe_sub(dev);
|
||||
if (ident != NULL) {
|
||||
device_set_desc(dev, ident->name);
|
||||
return (BUS_PROBE_DEFAULT);
|
||||
}
|
||||
return (ENXIO);
|
||||
}
|
||||
@ -591,13 +602,15 @@ rtwn_pci_attach_methods(struct rtwn_softc *sc)
|
||||
static int
|
||||
rtwn_pci_attach(device_t dev)
|
||||
{
|
||||
const struct rtwn_pci_ident *ident;
|
||||
struct rtwn_pci_softc *pc = device_get_softc(dev);
|
||||
struct rtwn_softc *sc = &pc->pc_sc;
|
||||
struct ieee80211com *ic = &sc->sc_ic;
|
||||
uint32_t lcsr;
|
||||
int cap_off, i, error, rid;
|
||||
|
||||
if (matched_chip >= RTWN_CHIP_MAX_PCI)
|
||||
ident = rtwn_pci_probe_sub(dev);
|
||||
if (ident == NULL)
|
||||
return (ENXIO);
|
||||
|
||||
/*
|
||||
@ -649,8 +662,7 @@ rtwn_pci_attach(device_t dev)
|
||||
mtx_init(&sc->sc_mtx, ic->ic_name, MTX_NETWORK_LOCK, MTX_DEF);
|
||||
|
||||
rtwn_pci_attach_methods(sc);
|
||||
/* XXX something similar to USB_GET_DRIVER_INFO() */
|
||||
rtwn_pci_attach_private(pc, matched_chip);
|
||||
rtwn_pci_attach_private(pc, ident->chip);
|
||||
|
||||
/* Allocate Tx/Rx buffers. */
|
||||
error = rtwn_pci_alloc_rx_list(sc);
|
||||
|
Loading…
x
Reference in New Issue
Block a user