NFS: Fix a memory leak in nfs_do_recoalesce
authorTrond Myklebust <trond.myklebust@primarydata.com>
Mon, 27 Jul 2015 14:23:19 +0000 (10:23 -0400)
committerTrond Myklebust <trond.myklebust@primarydata.com>
Mon, 27 Jul 2015 14:33:08 +0000 (10:33 -0400)
If the function exits early, then we must put those requests that were
not processed back onto the &mirror->pg_list so they can be cleaned up
by nfs_pgio_error().

Fixes: a7d42ddb30997 ("nfs: add mirroring support to pgio layer")
Cc: stable@vger.kernel.org # v4.0+
Signed-off-by: Trond Myklebust <trond.myklebust@primarydata.com>
fs/nfs/pagelist.c

index 1da68d3b1edabdb78c60527f502af5f40d6cf69b..8ea5920fb777576486bee23c6cd029d41f491aa0 100644 (file)
@@ -1109,8 +1109,11 @@ static int nfs_do_recoalesce(struct nfs_pageio_descriptor *desc)
                        nfs_list_remove_request(req);
                        if (__nfs_pageio_add_request(desc, req))
                                continue;
-                       if (desc->pg_error < 0)
+                       if (desc->pg_error < 0) {
+                               list_splice_tail(&head, &mirror->pg_list);
+                               mirror->pg_recoalesce = 1;
                                return 0;
+                       }
                        break;
                }
        } while (mirror->pg_recoalesce);