Skip to content

Commit fb4d64e

Browse files
Frederik DeweerdtLinus Torvalds
authored andcommitted
[PATCH] pci_iomap_regions() error handling fix
It appears that the pcim_iomap_regions() function doesn't get the error handling right. It BUGs early at boot with a backtrace along the lines of: ahci_init pci_register_driver driver_register [...] ahci_init_one pcim_iomap_region pcim_iounmap The following patch allows me to boot. Only the if(mask..) continue; part fixes the problem actually, the gotos where changed so that we don't try to unmap something we couldn't map anyway. Signed-off-by: Frederik Deweerdt <frederik.deweerdt@gmail.com> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Tejun Heo <htejun@gmail.com> Cc: Jeff Garzik <jeff@garzik.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent f5de611 commit fb4d64e

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎lib/devres.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,21 +274,21 @@ int pcim_iomap_regions(struct pci_dev *pdev, u16 mask, const char *name)
274274

275275
rc = pci_request_region(pdev, i, name);
276276
if (rc)
277-
goto err_region;
277+
goto err_inval;
278278

279279
rc = -ENOMEM;
280280
if (!pcim_iomap(pdev, i, 0))
281-
goto err_iomap;
281+
goto err_region;
282282
}
283283

284284
return 0;
285285

286-
err_iomap:
287-
pcim_iounmap(pdev, iomap[i]);
288286
err_region:
289287
pci_release_region(pdev, i);
290288
err_inval:
291289
while (--i >= 0) {
290+
if (!(mask & (1 << i)))
291+
continue;
292292
pcim_iounmap(pdev, iomap[i]);
293293
pci_release_region(pdev, i);
294294
}

0 commit comments

Comments
 (0)