Skip to content

Commit 2d25ee3

Browse files
committed
Merge branch 'bkl-removal' of git://git.lwn.net/linux-2.6
* 'bkl-removal' of git://git.lwn.net/linux-2.6: Fix a lockdep warning in fasync_helper() Add a missing unlock_kernel() in raw_open()
2 parents 915db32 + 4a6a449 commit 2d25ee3

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

drivers/char/raw.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ static int raw_open(struct inode *inode, struct file *filp)
9090
blkdev_put(bdev, filp->f_mode);
9191
out:
9292
mutex_unlock(&raw_mutex);
93+
unlock_kernel();
9394
return err;
9495
}
9596

fs/fcntl.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -531,6 +531,12 @@ int fasync_helper(int fd, struct file * filp, int on, struct fasync_struct **fap
531531
if (!new)
532532
return -ENOMEM;
533533
}
534+
535+
/*
536+
* We need to take f_lock first since it's not an IRQ-safe
537+
* lock.
538+
*/
539+
spin_lock(&filp->f_lock);
534540
write_lock_irq(&fasync_lock);
535541
for (fp = fapp; (fa = *fp) != NULL; fp = &fa->fa_next) {
536542
if (fa->fa_file == filp) {
@@ -555,14 +561,12 @@ int fasync_helper(int fd, struct file * filp, int on, struct fasync_struct **fap
555561
result = 1;
556562
}
557563
out:
558-
/* Fix up FASYNC bit while still holding fasync_lock */
559-
spin_lock(&filp->f_lock);
560564
if (on)
561565
filp->f_flags |= FASYNC;
562566
else
563567
filp->f_flags &= ~FASYNC;
564-
spin_unlock(&filp->f_lock);
565568
write_unlock_irq(&fasync_lock);
569+
spin_unlock(&filp->f_lock);
566570
return result;
567571
}
568572

include/linux/fs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ struct file {
849849
#define f_dentry f_path.dentry
850850
#define f_vfsmnt f_path.mnt
851851
const struct file_operations *f_op;
852-
spinlock_t f_lock; /* f_ep_links, f_flags */
852+
spinlock_t f_lock; /* f_ep_links, f_flags, no IRQ */
853853
atomic_long_t f_count;
854854
unsigned int f_flags;
855855
fmode_t f_mode;

0 commit comments

Comments
 (0)