Skip to content

Commit 015f021

Browse files
jtlaytonTrond Myklebust
authored andcommitted
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 f11ac8d. Reported-by: Steve Dickson <[email protected]> Signed-off-by: Jeff Layton <[email protected]> Cc: [email protected] Signed-off-by: Trond Myklebust <[email protected]>
1 parent 568a810 commit 015f021

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

fs/nfs/pagelist.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,13 @@ nfs_create_request(struct nfs_open_context *ctx, struct inode *inode,
6565
if (req == NULL)
6666
return ERR_PTR(-ENOMEM);
6767

68+
/* get lock context early so we can deal with alloc failures */
69+
req->wb_lock_context = nfs_get_lock_context(ctx);
70+
if (req->wb_lock_context == NULL) {
71+
nfs_page_free(req);
72+
return ERR_PTR(-ENOMEM);
73+
}
74+
6875
/* Initialize the request struct. Initially, we assume a
6976
* long write-back delay. This will be adjusted in
7077
* 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,
7986
req->wb_pgbase = offset;
8087
req->wb_bytes = count;
8188
req->wb_context = get_nfs_open_context(ctx);
82-
req->wb_lock_context = nfs_get_lock_context(ctx);
8389
kref_init(&req->wb_kref);
8490
return req;
8591
}

0 commit comments

Comments
 (0)