Skip to content

btrfs: add __free attribute and improve xattr cleanup

Leo Martins linux-btrfs 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 4 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2btrfs: use __free in linux/cleanup.h to reduce btrfs_free_path boilerplatefs/btrfs/ctree.c fs/btrfs/ctree.h+3 -10 replies
2/2btrfs: use __free to automatically free btrfs_path on exitfs/btrfs/xattr.c+8 -201 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/2] btrfs: add __free attribute and improve xattr cleanup

The first patch introduces the __free attribute to the btrfs code, allowing for automatic memory management of certain variables. This attribute enables the kernel to automatically call a specified function (in this case, btrfs_free_path()) on a variable when it goes out of scope, ensuring proper memory release and preventing potential memory leaks.

The second patch applies the __free attribute to the path variable in the btrfs_getxattr(), btrfs_setxattr(), and btrfs_listxattr() functions, ensuring that the memory allocated for this variable is properly released when it goes out of scope. This improves the memory management of xattr operations in btrfs, reducing the risk of memory-related bugs and improving overall system stability.

As a next step, I want to extend the use of the __free attribute to other instances where btrfs_free_path is being manually called.

Leo Martins (2):
btrfs: use __free in linux/cleanup.h to reduce btrfs_free_path
boilerplate
btrfs: use __free to automatically free btrfs_path on exit

 fs/btrfs/ctree.c |  3 ++-
 fs/btrfs/ctree.h |  1 +
 fs/btrfs/xattr.c | 28 ++++++++--------------------
 3 files changed, 11 insertions(+), 21 deletions(-)
Signature · 1 line
2.43.5