exofs: don't leak io_state and pages on read error
authorBoaz Harrosh <bharrosh@panasas.com>
Fri, 30 Nov 2012 14:03:31 +0000 (16:03 +0200)
committerBoaz Harrosh <bharrosh@panasas.com>
Fri, 14 Dec 2012 10:17:32 +0000 (12:17 +0200)
Same bug as fixed by Idan for write_exec was in read_exec.
Fix the io_state leak and pages state on read error.

Also while at it:
The if (!pcol->read_4_write) at the error path is redundant
because all goto err; are after the if (pcol->read_4_write)
bale out.

Signed-off-by: Boaz Harrosh <bharrosh@panasas.com>
fs/exofs/inode.c

index 1634b946565ff150d93ee65d1893a12a63bd6ac0..d1f80abd8828fcf3d8adadea9246effef03b7e29 100644 (file)
@@ -361,12 +361,12 @@ static int read_exec(struct page_collect *pcol)
        return 0;
 
 err:
-       if (!pcol->read_4_write)
-               _unlock_pcol_pages(pcol, ret, READ);
-
-       pcol_free(pcol);
-
+       if (!pcol_copy) /* Failed before ownership transfer */
+               pcol_copy = pcol;
+       _unlock_pcol_pages(pcol_copy, ret, READ);
+       pcol_free(pcol_copy);
        kfree(pcol_copy);
+
        return ret;
 }