Skip to content

Commit 3d8e560

Browse files
author
Jeff Layton
committed
locks: consolidate NULL i_flctx checks in locks_remove_file
We have each of the locks_remove_* variants doing this individually. Have the caller do it instead, and have locks_remove_flock and locks_remove_lease just assume that it's a valid pointer. Signed-off-by: Jeff Layton <jlayton@primarydata.com>
1 parent 9bd0f45 commit 3d8e560

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

fs/locks.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2400,6 +2400,7 @@ void locks_remove_posix(struct file *filp, fl_owner_t owner)
24002400

24012401
EXPORT_SYMBOL(locks_remove_posix);
24022402

2403+
/* The i_flctx must be valid when calling into here */
24032404
static void
24042405
locks_remove_flock(struct file *filp)
24052406
{
@@ -2413,7 +2414,7 @@ locks_remove_flock(struct file *filp)
24132414
};
24142415
struct file_lock_context *flctx = file_inode(filp)->i_flctx;
24152416

2416-
if (!flctx || list_empty(&flctx->flc_flock))
2417+
if (list_empty(&flctx->flc_flock))
24172418
return;
24182419

24192420
if (filp->f_op->flock)
@@ -2425,6 +2426,7 @@ locks_remove_flock(struct file *filp)
24252426
fl.fl_ops->fl_release_private(&fl);
24262427
}
24272428

2429+
/* The i_flctx must be valid when calling into here */
24282430
static void
24292431
locks_remove_lease(struct file *filp)
24302432
{
@@ -2433,7 +2435,7 @@ locks_remove_lease(struct file *filp)
24332435
struct file_lock *fl, *tmp;
24342436
LIST_HEAD(dispose);
24352437

2436-
if (!ctx || list_empty(&ctx->flc_lease))
2438+
if (list_empty(&ctx->flc_lease))
24372439
return;
24382440

24392441
spin_lock(&ctx->flc_lock);
@@ -2448,6 +2450,9 @@ locks_remove_lease(struct file *filp)
24482450
*/
24492451
void locks_remove_file(struct file *filp)
24502452
{
2453+
if (!file_inode(filp)->i_flctx)
2454+
return;
2455+
24512456
/* remove any OFD locks */
24522457
locks_remove_posix(filp, filp);
24532458

0 commit comments

Comments
 (0)