diff options
author | Christian Brauner <brauner@kernel.org> | 2024-06-07 16:55:35 +0200 |
---|---|---|
committer | Christian Brauner <brauner@kernel.org> | 2024-06-28 09:52:05 +0200 |
commit | ff2c570ef7eaa9ded58e7a02dd7a68874a897508 (patch) | |
tree | 51356b4b7d9a8dc7061ae24168fa03f21cee9080 /include | |
parent | 1613e604df0cd359cf2a7fbd9be7a0bcfacfabd0 (diff) |
path: add cleanup helper
Add a simple cleanup helper so we can cleanup struct path easily.
No need for any extra machinery. Avoid DEFINE_FREE() as it causes a
local copy of struct path to be used. Just rely on path_put() directly
called from a cleanup helper.
Link: https://lore.kernel.org/r/20240607-vfs-listmount-reverse-v1-2-7877a2bfa5e5@kernel.org
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Signed-off-by: Christian Brauner <brauner@kernel.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/path.h | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/include/linux/path.h b/include/linux/path.h index 475225a03d0d..ca073e70decd 100644 --- a/include/linux/path.h +++ b/include/linux/path.h @@ -24,4 +24,13 @@ static inline void path_put_init(struct path *path) *path = (struct path) { }; } +/* + * Cleanup macro for use with __free(path_put). Avoids dereference and + * copying @path unlike DEFINE_FREE(). path_put() will handle the empty + * path correctly just ensure @path is initialized: + * + * struct path path __free(path_put) = {}; + */ +#define __free_path_put path_put + #endif /* _LINUX_PATH_H */ |