diff options
author | Jeff Layton <jlayton@redhat.com> | 2010-10-28 10:10:37 -0400 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2010-10-28 11:17:25 -0400 |
commit | 015f0212d51d85bd281a831639a769b4a1a3307a (patch) | |
tree | e873e64419d0a5e1000de1ce8f91e28f0ec5ac41 /fs/nfs | |
parent | 568a810d7edd58bd505222dd1c7e48895532290b (diff) | |
download | linux-3.10-015f0212d51d85bd281a831639a769b4a1a3307a.tar.gz linux-3.10-015f0212d51d85bd281a831639a769b4a1a3307a.tar.bz2 linux-3.10-015f0212d51d85bd281a831639a769b4a1a3307a.zip |
nfs: handle lock context allocation failures in nfs_create_request
nfs_get_lock_context can return NULL on an allocation failure.
Regression introduced by commit f11ac8db.
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>
Diffstat (limited to 'fs/nfs')
-rw-r--r-- | fs/nfs/pagelist.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c index 919490232e1..137b549e63d 100644 --- a/fs/nfs/pagelist.c +++ b/fs/nfs/pagelist.c @@ -65,6 +65,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. */ @@ -79,7 +86,6 @@ nfs_create_request(struct nfs_open_context *ctx, struct inode *inode, req->wb_pgbase = offset; req->wb_bytes = count; req->wb_context = get_nfs_open_context(ctx); - req->wb_lock_context = nfs_get_lock_context(ctx); kref_init(&req->wb_kref); return req; } |