2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-25 13:43:55 +08:00
linux-next/scripts/coccinelle/free
Yann Droneaud b7b2ee41f3 coccinelle: catch krealloc() on devm_*() allocated memory
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>
Acked-by: Julia Lawall <julia.lawall@lip6.fr>
Signed-off-by: Yann Droneaud <ydroneaud@opteya.com>
Signed-off-by: Michal Marek <mmarek@suse.com>
2016-06-21 11:43:32 +02:00
..
clk_put.cocci coccinelle: semantic patch for missing clk_put 2012-02-25 00:07:11 +01:00
devm_free.cocci coccinelle: catch krealloc() on devm_*() allocated memory 2016-06-21 11:43:32 +02:00
ifnullfree.cocci coccinelle: also catch kzfree() issues 2016-06-21 11:43:32 +02:00
iounmap.cocci coccinelle: semantic patch for missing iounmap 2012-02-25 00:07:11 +01:00
kfree.cocci coccinelle: also catch kzfree() issues 2016-06-21 11:43:32 +02:00
kfreeaddr.cocci coccinelle: also catch kzfree() issues 2016-06-21 11:43:32 +02:00
pci_free_consistent.cocci scripts: Coccinelle script for pci_free_consistent() 2013-07-03 15:50:38 +02:00