]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
mount-util: make umount_and_rmdir_and_freep() cleanup handler deal with NULL
authorLennart Poettering <lennart@poettering.net>
Mon, 19 Apr 2021 20:50:32 +0000 (22:50 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 20 Apr 2021 08:23:30 +0000 (10:23 +0200)
src/shared/mount-util.h

index 718389768605233971462af33ab8c6c480294fb7..6469181d1cf46a37ca1124f48ba6a6175e55f039 100644 (file)
@@ -93,8 +93,10 @@ int mode_to_inaccessible_node(const char *runtime_dir, mode_t mode, char **dest)
 /* Useful for usage with _cleanup_(), unmounts, removes a directory and frees the pointer */
 static inline char* umount_and_rmdir_and_free(char *p) {
         PROTECT_ERRNO;
-        (void) umount_recursive(p, 0);
-        (void) rmdir(p);
+        if (p) {
+                (void) umount_recursive(p, 0);
+                (void) rmdir(p);
+        }
         return mfree(p);
 }
 DEFINE_TRIVIAL_CLEANUP_FUNC(char*, umount_and_rmdir_and_free);