Commit ae891a1b93bf62e9aaa116a7a71312375047fc9f

Authored by Maxin B John
Committed by Linus Torvalds
1 parent 5190f0c030

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: Maxin B. John <maxin.john@gmail.com>
Reviewed-by: Rolf Eike Beer <eike-kernel@sf-tec.de>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 3 changed files with 3 additions and 3 deletions Side-by-side Diff

... ... @@ -87,9 +87,9 @@
87 87 {
88 88 struct irq_devres match_data = { irq, dev_id };
89 89  
90   - free_irq(irq, dev_id);
91 90 WARN_ON(devres_destroy(dev, devm_irq_release, devm_irq_match,
92 91 &match_data));
  92 + free_irq(irq, dev_id);
93 93 }
94 94 EXPORT_SYMBOL(devm_free_irq);
... ... @@ -79,9 +79,9 @@
79 79 */
80 80 void devm_iounmap(struct device *dev, void __iomem *addr)
81 81 {
82   - iounmap(addr);
83 82 WARN_ON(devres_destroy(dev, devm_ioremap_release, devm_ioremap_match,
84 83 (void *)addr));
  84 + iounmap(addr);
85 85 }
86 86 EXPORT_SYMBOL(devm_iounmap);
87 87  
... ... @@ -500,8 +500,8 @@
500 500 {
501 501 struct device *dev = pool->dev;
502 502  
503   - dma_pool_destroy(pool);
504 503 WARN_ON(devres_destroy(dev, dmam_pool_release, dmam_pool_match, pool));
  504 + dma_pool_destroy(pool);
505 505 }
506 506 EXPORT_SYMBOL(dmam_pool_destroy);