Skip to content

Commit 0671d8f

Browse files
elfringamschuma-ntap
authored andcommitted
nfs/write: Use common error handling code in nfs_lock_and_join_requests()
Add a jump target so that a bit of exception handling can be better reused at the end of this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Anna Schumaker <Anna.Schumaker@Netapp.com>
1 parent fcd8843 commit 0671d8f

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

fs/nfs/write.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -487,10 +487,8 @@ nfs_lock_and_join_requests(struct page *page)
487487
}
488488

489489
ret = nfs_page_group_lock(head);
490-
if (ret < 0) {
491-
nfs_unlock_and_release_request(head);
492-
return ERR_PTR(ret);
493-
}
490+
if (ret < 0)
491+
goto release_request;
494492

495493
/* lock each request in the page group */
496494
total_bytes = head->wb_bytes;
@@ -515,8 +513,7 @@ nfs_lock_and_join_requests(struct page *page)
515513
if (ret < 0) {
516514
nfs_unroll_locks(inode, head, subreq);
517515
nfs_release_request(subreq);
518-
nfs_unlock_and_release_request(head);
519-
return ERR_PTR(ret);
516+
goto release_request;
520517
}
521518
}
522519
/*
@@ -532,8 +529,8 @@ nfs_lock_and_join_requests(struct page *page)
532529
nfs_page_group_unlock(head);
533530
nfs_unroll_locks(inode, head, subreq);
534531
nfs_unlock_and_release_request(subreq);
535-
nfs_unlock_and_release_request(head);
536-
return ERR_PTR(-EIO);
532+
ret = -EIO;
533+
goto release_request;
537534
}
538535
}
539536

@@ -576,6 +573,10 @@ nfs_lock_and_join_requests(struct page *page)
576573
/* still holds ref on head from nfs_page_find_head_request
577574
* and still has lock on head from lock loop */
578575
return head;
576+
577+
release_request:
578+
nfs_unlock_and_release_request(head);
579+
return ERR_PTR(ret);
579580
}
580581

581582
static void nfs_write_error_remove_page(struct nfs_page *req)

0 commit comments

Comments
 (0)