Skip to content

Commit ff2c570

Browse files
committed
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]>
1 parent 1613e60 commit ff2c570

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

include/linux/path.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,13 @@ static inline void path_put_init(struct path *path)
2424
*path = (struct path) { };
2525
}
2626

27+
/*
28+
* Cleanup macro for use with __free(path_put). Avoids dereference and
29+
* copying @path unlike DEFINE_FREE(). path_put() will handle the empty
30+
* path correctly just ensure @path is initialized:
31+
*
32+
* struct path path __free(path_put) = {};
33+
*/
34+
#define __free_path_put path_put
35+
2736
#endif /* _LINUX_PATH_H */

0 commit comments

Comments
 (0)