提交 ae891a1b 编写于 作者: M Maxin B John 提交者: Linus Torvalds

devres: fix possible use after free

devres uses the pointer value as key after it's freed, which is safe but
triggers spurious use-after-free warnings on some static analysis tools.
Rearrange code to avoid such warnings.
Signed-off-by: NMaxin B. John <maxin.john@gmail.com>
Reviewed-by: NRolf Eike Beer <eike-kernel@sf-tec.de>
Acked-by: NTejun Heo <tj@kernel.org>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 5190f0c0
...@@ -87,8 +87,8 @@ void devm_free_irq(struct device *dev, unsigned int irq, void *dev_id) ...@@ -87,8 +87,8 @@ void devm_free_irq(struct device *dev, unsigned int irq, void *dev_id)
{ {
struct irq_devres match_data = { irq, dev_id }; struct irq_devres match_data = { irq, dev_id };
free_irq(irq, dev_id);
WARN_ON(devres_destroy(dev, devm_irq_release, devm_irq_match, WARN_ON(devres_destroy(dev, devm_irq_release, devm_irq_match,
&match_data)); &match_data));
free_irq(irq, dev_id);
} }
EXPORT_SYMBOL(devm_free_irq); EXPORT_SYMBOL(devm_free_irq);
...@@ -79,9 +79,9 @@ EXPORT_SYMBOL(devm_ioremap_nocache); ...@@ -79,9 +79,9 @@ EXPORT_SYMBOL(devm_ioremap_nocache);
*/ */
void devm_iounmap(struct device *dev, void __iomem *addr) void devm_iounmap(struct device *dev, void __iomem *addr)
{ {
iounmap(addr);
WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match, WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
(void *)addr)); (void *)addr));
iounmap(addr);
} }
EXPORT_SYMBOL(devm_iounmap); EXPORT_SYMBOL(devm_iounmap);
......
...@@ -500,7 +500,7 @@ void dmam_pool_destroy(struct dma_pool *pool) ...@@ -500,7 +500,7 @@ void dmam_pool_destroy(struct dma_pool *pool)
{ {
struct device *dev = pool->dev; struct device *dev = pool->dev;
dma_pool_destroy(pool);
WARN_ON(devres_destroy(dev, dmam_pool_release, dmam_pool_match, pool)); WARN_ON(devres_destroy(dev, dmam_pool_release, dmam_pool_match, pool));
dma_pool_destroy(pool);
} }
EXPORT_SYMBOL(dmam_pool_destroy); EXPORT_SYMBOL(dmam_pool_destroy);
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册