mvsas mvs_pci_alloc() error handling
When playing with mvsas (on 2.6.34-rc4 ish), I ran into this:
WARNING: at /data/buytenh/linux-2.6/mm/vmalloc.c:1368 __vunmap+0x58/0xdc() Trying to vfree() nonexistent vm area (f0800000)
If ->chip_ioremap() fails, mvs_pci_alloc() will call mvs_free(), which calls ->chip_iounmap(), which tries to free something that couldn't be allocated in the first place.
A quick second glance at mvs_pci_alloc() turns up more fishy stuff, for example:
do {
mvi = mvs_pci_alloc(pdev, ent, shost, nhost);
if (!mvi) {
rc = -ENOMEM;
goto err_out_regions;
}
mvs_init_sas_add(mvi);
mvi->instance = nhost;
rc = MVS_CHIP_DISP->chip_init(mvi);
if (rc) {
mvs_free(mvi);
goto err_out_regions;
}
nhost++;
} while (nhost < chip->n_host);I.e. if mvs_pci_alloc() or ->chip_init() fails for an mvi, we will free this mvi but not any of the ones previously allocated in this loop.