Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 27922b4260f65d317aabda37e42bbbff > files > 1134

kernel-2.6.18-238.el5.src.rpm

From: Jeff Layton <jlayton@redhat.com>
Date: Fri, 10 Dec 2010 18:07:01 -0500
Subject: [fs] nfs: handle alloc failures in nfs_create_request
Message-id: <1292004422-17475-3-git-send-email-jlayton@redhat.com>
Patchwork-id: 30076
O-Subject: [RHEL5.6 PATCH 2/3] BZ#656492: nfs: handle lock context allocation
	failures in nfs_create_request
Bugzilla: 656492
RH-Acked-by: J. Bruce Fields <bfields@redhat.com>

nfs_get_lock_context can return NULL on an allocation failure.
Regression introduced by commit f11ac8db.

Upstream commit: 015f0212d51d85bd281a831639a769b4a1a3307a
Reported-by: Steve Dickson <steved@redhat.com>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Cc: stable@kernel.org
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>

diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c
index e4b560b..c5dcdf4 100644
--- a/fs/nfs/pagelist.c
+++ b/fs/nfs/pagelist.c
@@ -67,6 +67,13 @@ nfs_create_request(struct nfs_open_context *ctx, struct inode *inode,
 	if (req == NULL)
 		return ERR_PTR(-ENOMEM);
 
+	/* get lock context early so we can deal with alloc failures */
+	req->wb_lock_context = nfs_get_lock_context(ctx);
+	if (req->wb_lock_context == NULL) {
+		nfs_page_free(req);
+		return ERR_PTR(-ENOMEM);
+	}
+
 	/* Initialize the request struct. Initially, we assume a
 	 * long write-back delay. This will be adjusted in
 	 * update_nfs_request below if the region is not locked. */
@@ -82,7 +89,6 @@ nfs_create_request(struct nfs_open_context *ctx, struct inode *inode,
 	req->wb_bytes   = count;
 	atomic_set(&req->wb_count, 1);
 	req->wb_context = get_nfs_open_context(ctx);
-	req->wb_lock_context = nfs_get_lock_context(ctx);
 
 	return req;
 }