Btrfs: use kmem_cache_free when freeing entry in inode cache
authorFilipe Manana <fdmanana@suse.com>
Sat, 13 Jun 2015 05:52:56 +0000 (06:52 +0100)
committerDanny Wood <danwood76@gmail.com>
Tue, 29 Jan 2019 13:09:25 +0000 (13:09 +0000)
commita654c0923c56c65121dda9c161be8c84b860d9aa
tree24eb865b458a6cb2c127eeb6265bc444db431b2c
parent682e5fc0ec8f6cec8cb7fc2519cdf95a702afd33
Btrfs: use kmem_cache_free when freeing entry in inode cache

commit c3f4a1685bb87e59c886ee68f7967eae07d4dffa upstream.

The free space entries are allocated using kmem_cache_zalloc(),
through __btrfs_add_free_space(), therefore we should use
kmem_cache_free() and not kfree() to avoid any confusion and
any potential problem. Looking at the kfree() definition at
mm/slab.c it has the following comment:

  /*
   * (...)
   *
   * Don't free memory not originally allocated by kmalloc()
   * or you will run into trouble.
   */

So better be safe and use kmem_cache_free().

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: David Sterba <dsterba@suse.cz>
Signed-off-by: Chris Mason <clm@fb.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/btrfs/inode-map.c