rebuild_wim(): Fix possible problem with fd closing
authorEric Biggers <ebiggers3@gmail.com>
Mon, 12 Nov 2012 20:19:27 +0000 (14:19 -0600)
committerEric Biggers <ebiggers3@gmail.com>
Mon, 12 Nov 2012 20:19:27 +0000 (14:19 -0600)
Use list_for_each_entry_safe() instead of list_for_each_entry() when closing
staging file descriptors, since a lookup table entry may be deleted when its
last file descriptor is closed.

src/mount.c

index 6bc1fdff0e2e2c110f0bdff031413d019b1aadf9..54c7b0990d8726d75cb7e884e38af238fb5b5b61 100644 (file)
@@ -876,7 +876,7 @@ static int rebuild_wim(struct wimfs_context *ctx, bool check_integrity)
 
 
        DEBUG("Closing all staging file descriptors.");
-       list_for_each_entry(lte, &ctx->staging_list, staging_list) {
+       list_for_each_entry_safe(lte, tmp, &ctx->staging_list, staging_list) {
                ret = inode_close_fds(lte->lte_inode);
                if (ret != 0)
                        return ret;