locks: fix NULL-deref in generic_delete_lease
authorNeilBrown <[email protected]>
Tue, 13 Jan 2015 02:17:43 +0000 (15:17 +1300)
committerJeff Layton <[email protected]>
Tue, 13 Jan 2015 12:00:55 +0000 (07:00 -0500)
commit 0efaa7e82f02fe69c05ad28e905f31fc86e6f08e
  locks: generic_delete_lease doesn't need a file_lock at all

moves the call to fl->fl_lmops->lm_change() to a place in the
code where fl might be a non-lease lock.
When that happens, fl_lmops is NULL and an Oops ensures.

So add an extra test to restore correct functioning.

Reported-by: Linda Walsh <[email protected]>
Link: https://bugzilla.suse.com/show_bug.cgi?id=912569
Cc: [email protected] (v3.18)
Fixes: 0efaa7e82f02fe69c05ad28e905f31fc86e6f08e
Signed-off-by: NeilBrown <[email protected]>
Signed-off-by: Jeff Layton <[email protected]>
fs/locks.c

index 735b8d3fa78c92bf746aff05475be1fa2a82abd6..59e2f905e4ffea324dbf44faf1b666974adc6c23 100644 (file)
@@ -1702,7 +1702,7 @@ static int generic_delete_lease(struct file *filp)
                        break;
        }
        trace_generic_delete_lease(inode, fl);
-       if (fl)
+       if (fl && IS_LEASE(fl))
                error = fl->fl_lmops->lm_change(before, F_UNLCK, &dispose);
        spin_unlock(&inode->i_lock);
        locks_dispose_list(&dispose);