From: Leo Martins <loemra.dev@gmail.com>
To: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: [PATCH 0/2] btrfs: add __free attribute and improve xattr cleanup
Date: Fri, 9 Aug 2024 16:11:47 -0700 [thread overview]
Message-ID: <cover.1723245033.git.loemra.dev@gmail.com> (raw)
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(-)
--
2.43.5
next reply other threads:[~2024-08-09 23:13 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-09 23:11 Leo Martins [this message]
2024-08-09 23:11 ` [PATCH 1/2] btrfs: use __free in linux/cleanup.h to reduce btrfs_free_path boilerplate Leo Martins
2024-08-09 23:11 ` [PATCH 2/2] btrfs: use __free to automatically free btrfs_path on exit Leo Martins
2024-08-13 21:34 ` David Sterba
2024-08-13 21:29 ` [PATCH 0/2] btrfs: add __free attribute and improve xattr cleanup David Sterba
2024-08-15 17:38 ` Leo Martins
2024-08-15 18:46 ` David Sterba
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1723245033.git.loemra.dev@gmail.com \
--to=loemra.dev@gmail.com \
--cc=kernel-team@fb.com \
--cc=linux-btrfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox