Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1335684 > unrolled thread
| Started by | Yann Droneaud <ydroneaud@opteya.com> |
|---|---|
| First post | 2016-02-16 19:00 +0100 |
| Last post | 2016-02-16 19:00 +0100 |
| Articles | 1 — 1 participant |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[PATCH 3/3] coccinelle: catch krealloc() on devm_*() allocated memory Yann Droneaud <ydroneaud@opteya.com> - 2016-02-16 19:00 +0100
| From | Yann Droneaud <ydroneaud@opteya.com> |
|---|---|
| Date | 2016-02-16 19:00 +0100 |
| Subject | [PATCH 3/3] coccinelle: catch krealloc() on devm_*() allocated memory |
| Message-ID | <r2RBM-2tA-7@gated-at.bofh.it> |
krealloc() must not be used against devm_*() allocated memory regions: - if a bigger memory is to be allocated, krealloc() and __krealloc() could return a different pointer than the one given to them, creating a memory region which is not managed, thus it will not be automatically released on device removal. - if a bigger memory is to be allocated, krealloc() could kfree() the managed memory region which is passed to it. The old pointer is left registered as a resource for the device. On device removal, this dangling pointer will be used and an unrelated memory region could be released. - if the requested size is equal to 0, krealloc() can also just behave like kfree(). Here too, the old pointer is kept associated with the device. On device removal, this invalid pointer will be used and an unrelated memory region could be released. For all these reasons, krealloc() must not be used on a pointer returned by devm_*() functions. Cc: Tejun Heo <tj@kernel.org> Cc: Pekka Enberg <penberg@cs.helsinki.fi> Signed-off-by: Yann Droneaud <ydroneaud@opteya.com> --- scripts/coccinelle/free/devm_free.cocci | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/coccinelle/free/devm_free.cocci b/scripts/coccinelle/free/devm_free.cocci index 3794cd97494b..c990d2c7ee16 100644 --- a/scripts/coccinelle/free/devm_free.cocci +++ b/scripts/coccinelle/free/devm_free.cocci @@ -66,6 +66,10 @@ position p; | * kzfree@p(x) | +* __krealloc@p(x, ...) +| +* krealloc@p(x, ...) +| * free_pages@p(x, ...) | * free_page@p(x) -- 2.5.0
Back to top | Article view | linux.kernel
csiph-web