]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
Revert "util:bind_remount_recursive() fix "use after free""
authorHarald Hoyer <harald@redhat.com>
Tue, 9 Jun 2015 08:31:14 +0000 (10:31 +0200)
committerHarald Hoyer <harald@redhat.com>
Tue, 9 Jun 2015 08:31:14 +0000 (10:31 +0200)
This reverts commit 46be6129d3e52556eb0f2ae4d07818f9f3f7af7a.

src/shared/util.c

index 1442301cd7f0cbaaeca67ba8ac099af96f1742d9..311acbb3499384c5d28df4a9ee5a7b13a049e7db 100644 (file)
@@ -4931,15 +4931,11 @@ int bind_remount_recursive(const char *prefix, bool ro) {
 
                 while ((x = set_steal_first(todo))) {
 
-                        r = set_put(done, x);
-                        if (r == -EEXIST) {
-                                free(x);
+                        r = set_consume(done, x);
+                        if (r == -EEXIST)
                                 continue;
-                        }
-                        if (r < 0) {
-                                free(x);
+                        if (r < 0)
                                 return r;
-                        }
 
                         /* Try to reuse the original flag set, but
                          * don't care for errors, in case of
@@ -4949,15 +4945,14 @@ int bind_remount_recursive(const char *prefix, bool ro) {
                         orig_flags &= ~MS_RDONLY;
 
                         if (mount(NULL, x, NULL, orig_flags|MS_BIND|MS_REMOUNT|(ro ? MS_RDONLY : 0), NULL) < 0) {
+
                                 /* Deal with mount points that are
                                  * obstructed by a later mount */
 
-                                if (errno != ENOENT) {
-                                        free(x);
+                                if (errno != ENOENT)
                                         return -errno;
-                                }
                         }
-                        free(x);
+
                 }
         }
 }