* [patch] devres: fix a for loop bounds check [not found] <20150916171000.GD3243@mtj.duckdns.org> @ 2015-09-21 16:21 ` Dan Carpenter 2015-09-21 17:40 ` Tejun Heo 0 siblings, 1 reply; 2+ messages in thread From: Dan Carpenter @ 2015-09-21 16:21 UTC (permalink / raw) To: Greg Kroah-Hartman, htejun Cc: Catalin Marinas, Cristian Stoica, Dan Williams, Abhilash Kesavan, linux-kernel, kernel-janitors The iomap[] array has PCIM_IOMAP_MAX (6) elements and not DEVICE_COUNT_RESOURCE (16). This bug was found using a static checker. It may be that the "if (!(mask & (1 << i)))" check means we never actually go past the end of the array in real life. Fixes: ec04b075843d ('iomap: implement pcim_iounmap_regions()') Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> diff --git a/lib/devres.c b/lib/devres.c index f13a246..8c85672 100644 --- a/lib/devres.c +++ b/lib/devres.c @@ -418,7 +418,7 @@ void pcim_iounmap_regions(struct pci_dev *pdev, int mask) if (!iomap) return; - for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { + for (i = 0; i < PCIM_IOMAP_MAX; i++) { if (!(mask & (1 << i))) continue; ^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [patch] devres: fix a for loop bounds check 2015-09-21 16:21 ` [patch] devres: fix a for loop bounds check Dan Carpenter @ 2015-09-21 17:40 ` Tejun Heo 0 siblings, 0 replies; 2+ messages in thread From: Tejun Heo @ 2015-09-21 17:40 UTC (permalink / raw) To: Dan Carpenter Cc: Greg Kroah-Hartman, Catalin Marinas, Cristian Stoica, Dan Williams, Abhilash Kesavan, linux-kernel, kernel-janitors On Mon, Sep 21, 2015 at 07:21:51PM +0300, Dan Carpenter wrote: > The iomap[] array has PCIM_IOMAP_MAX (6) elements and not > DEVICE_COUNT_RESOURCE (16). This bug was found using a static checker. > It may be that the "if (!(mask & (1 << i)))" check means we never > actually go past the end of the array in real life. > > Fixes: ec04b075843d ('iomap: implement pcim_iounmap_regions()') > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Acked-by: Tejun Heo <tj@kernel.org> Thanks. -- tejun ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-09-21 17:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20150916171000.GD3243@mtj.duckdns.org>
2015-09-21 16:21 ` [patch] devres: fix a for loop bounds check Dan Carpenter
2015-09-21 17:40 ` Tejun Heo
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox
Powered by JetHome