aboutsummaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorChristian Brauner <[email protected]>2024-06-07 16:55:35 +0200
committerChristian Brauner <[email protected]>2024-06-28 09:52:05 +0200
commitff2c570ef7eaa9ded58e7a02dd7a68874a897508 (patch)
tree51356b4b7d9a8dc7061ae24168fa03f21cee9080 /include/linux
parent1613e604df0cd359cf2a7fbd9be7a0bcfacfabd0 (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/[email protected] Reviewed-by: Josef Bacik <[email protected]> Signed-off-by: Christian Brauner <[email protected]>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/path.h9
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 */