Skip to content

Commit

Permalink
nfs: handle lock context allocation failures in nfs_create_request
Browse files Browse the repository at this point in the history
nfs_get_lock_context can return NULL on an allocation failure.
Regression introduced by commit f11ac8d.

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>
  • Loading branch information
Jeff Layton authored and Trond Myklebust committed Oct 28, 2010
1 parent 568a810 commit 015f021
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion fs/nfs/pagelist.c
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand All @@ -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;
}
Expand Down

0 comments on commit 015f021

Please sign in to comment.