# DF-4969 — adw_pci_attach error unwinds leak the PCI register/IRQ resources (and the softc on the setup() path): adw_free() never calls bus_release_resource

**File:** `sys/dev/disk/advansys/adw_pci.c:242-245,265-270,274-278,295-298,300-303` (+ `adwcam.c:844-886`)
**Class:** boot/attach-time kernel resource leak (no unwind pairing)
**Severity:** Low (requires AdvanSys PCI hardware present + an init failure; legacy driver)
**Bucket:** legacy (advansys)

## Reproduce (static trace — runtime needs AdvanSys hardware, absent on this guest)

```
sh adw_static_check.sh [srcdir]   # default /usr/src/sys/dev/disk/advansys
```

Prints the exact cited lines from the running kernel's source: every error path after
`regs = bus_alloc_resource(...)` calls only `adw_free(adw)` — which frees the DMA
hierarchy and the softc but **never** releases `regs` (or `irq` once allocated, and never
tears down the interrupt), and the `entry->setup()` failure path at `adw_pci.c:244-245`
returns **without even `adw_free(adw)`**, leaking the `M_INTWAIT`-allocated softc and the
register resource.

## Runtime preconditions (why untested here)

The driver *is* compiled into the default kernel (`sys/config/X86_64_GENERIC:101
device adw`) — but attach requires a PCI device with AdvanSys IDs (0x10CD). This guest
(`pciconf -l`, see env.txt) has none, so probe never matches and no runtime trigger
exists. On real hardware the leak fires whenever attach fails after `regs` is allocated:
failed `adw_find_signature` (bogus/absent chip), failed `bus_dma_tag_create`, failed
`adw_init` (bad EEPROM checksum / chip wedge → `adw_init_chip` ENXIO), failed IRQ
allocation, or failed `bus_setup_intr`. Flaky hardware or IRQ exhaustion (kldload after
boot with the card present) makes repeat-probe leaks possible: each failed attach leaks
one I/O or memory BAR resource + the softc, and the device can never attach cleanly
afterwards (the resource stays rman-owned by the failed unit).
