--- linux-2.4.22-up/fs/locks.c.orig 2002-05-30 14:07:49.000000000 -0400 +++ linux-2.4.22-up/fs/locks.c 2003-11-15 01:12:16.000000000 -0500 @@ -1747,7 +1747,14 @@ before = &inode->i_flock; while ((fl = *before) != NULL) { if ((fl->fl_flags & FL_POSIX) && fl->fl_owner == owner) { + struct file *filp = fl->fl_file; + /* Note: locks_unlock_delete() can sleep, and + * so we may race with the call to sys_close() + * by the thread that actually owns this filp. + */ + get_file(filp); locks_unlock_delete(before); + fput(filp); before = &inode->i_flock; continue; }