diff options
Diffstat (limited to 'scripts/coccinelle/free/devm_free.cocci')
| -rw-r--r-- | scripts/coccinelle/free/devm_free.cocci | 66 |
1 files changed, 56 insertions, 10 deletions
diff --git a/scripts/coccinelle/free/devm_free.cocci b/scripts/coccinelle/free/devm_free.cocci index c990d2c7ee16..0880729badbc 100644 --- a/scripts/coccinelle/free/devm_free.cocci +++ b/scripts/coccinelle/free/devm_free.cocci @@ -1,8 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0-only /// Find uses of standard freeing functons on values allocated using devm_ /// functions. Values allocated using the devm_functions are freed when /// the device is detached, and thus the use of the standard freeing /// function would cause a double free. -/// See Documentation/driver-model/devres.txt for more information. +/// See Documentation/driver-api/driver-model/devres.rst for more information. /// /// A difficulty of detecting this problem is that the standard freeing /// function might be called from a different function than the one @@ -14,9 +15,9 @@ /// less reliable in these cases. /// // Confidence: Moderate -// Copyright: (C) 2011 Julia Lawall, INRIA/LIP6. GPLv2. -// Copyright: (C) 2011 Gilles Muller, INRIA/LiP6. GPLv2. -// URL: http://coccinelle.lip6.fr/ +// Copyright: (C) 2011 Julia Lawall, INRIA/LIP6. +// Copyright: (C) 2011 Gilles Muller, INRIA/LiP6. +// URL: https://coccinelle.gitlabpages.inria.fr/website // Comments: // Options: --no-includes --include-headers @@ -51,22 +52,67 @@ expression x; | x = devm_ioremap(...) | - x = devm_ioremap_nocache(...) -| x = devm_ioport_map(...) ) +@safe depends on context || org || report exists@ +expression x; +position p; +@@ + +( + x = kmalloc(...) +| + x = kvasprintf(...) +| + x = kasprintf(...) +| + x = kzalloc(...) +| + x = kmalloc_array(...) +| + x = kcalloc(...) +| + x = kstrdup(...) +| + x = kmemdup(...) +| + x = get_free_pages(...) +| + x = request_irq(...) +| + x = ioremap(...) +| + x = ioport_map(...) +) +... +( + kfree@p(x) +| + kfree_sensitive@p(x) +| + krealloc@p(x, ...) +| + free_pages@p(x, ...) +| + free_page@p(x) +| + free_irq@p(x) +| + iounmap@p(x) +| + ioport_unmap@p(x) +) + @pb@ expression r.x; -position p; +position p != safe.p; @@ ( * kfree@p(x) | -* kzfree@p(x) -| -* __krealloc@p(x, ...) +* kfree_sensitive@p(x) | * krealloc@p(x, ...) | |
